-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add helpful error message for 'uv activate' #17001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add helpful error message for 'uv activate' #17001
Conversation
When users try to run 'uv activate', show a helpful error message instead of the generic unknown command error. The message explains that 'uv activate' is not supported and provides instructions on how to activate a virtual environment. This addresses issue astral-sh#16993.
|
@charliermarsh @zanieb FYI! |
|
darth-raijin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small suggestion about some possibly redundant comments
crates/uv/src/lib.rs
Outdated
| ); | ||
| } | ||
| "activate" => { | ||
| // Handle "activate" with a helpful error message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The code already makes this intent pretty clear, so these two comments might be redundant. Fine to keep, but you could consider removing.
|
I'm still not sure we should do this, but if we do, we probably need to actually use our shell detection logic as well as discover the virtual environment to ensure one exists? |
|
+1 on the above. It feels like it could set a precedent for adding similar custom messages for other unsupported commands, instead of handling them in a more general way. |
- Detect user's current shell (Bash, Zsh, Fish, Nushell, Csh, PowerShell, Cmd) - Search for virtual environment in current and parent directories - Provide shell-specific activation command with correct path - Show helpful hint when no venv is found Addresses feedback from @zanieb to use shell detection logic and discover the virtual environment.
|
Hey, updated this based on @zanieb's feedback! Now it actually detects your shell and finds the venv instead of just printing static text. Walks up from cwd looking for Quick examples: If you're in fish: No venv? Shows a hint: @darth-raijin - fair point on precedent, but we already do this for |
When users try to run 'uv activate', show a helpful error message
instead of the generic unknown command error. The message explains
that 'uv activate' is not supported and provides instructions on
how to activate a virtual environment.
This is most probably address the issue: #16993