Skip to content
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

Add option for --active flag to be used as default #11458

Closed
Nick-Hemenway opened this issue Feb 12, 2025 · 1 comment
Closed

Add option for --active flag to be used as default #11458

Nick-Hemenway opened this issue Feb 12, 2025 · 1 comment
Labels
enhancement New feature or improvement to existing functionality

Comments

@Nick-Hemenway
Copy link

Summary

There seems to be a lot of interest in enabling uv to reference virtual environments located in a central location on your computer (as opposed to in a .venv folder located in the project's directory) (See #1495). It doesn't appear that there's an immediate plan to support this functionality (at least not through an interface that resembles those of virtualenvwrapper, pyenv, or poetry).

There's a bit of workaround, however. A user can use an external virtual environment by creating it, activating it, and then adding a --active flag to each invocation of uv. It might look something like this:

>>> uv venv ~/.virtualenvs/my_venv
>>> source ~/.virtualenvs/my_venv/Scripts/activate
>>> uv add --active numpy pandas jupyterlab
>>> uv remove --active pandas
>>> uv sync --active

This workflow is fine, but it's kind of tedious remembering to add the --active flag all the time. Especially because if you forget to add the flag, uv will automatically create a new .venv folder in your project directory that you have to delete.

My request is to please add the option (perhaps through an environment variable?) to make the --active flag the default behavior. If enabled as the default, it would make sense to raise an error message if a user tries to call uv add (or similar applicable commands) without a virtual environment currently active.

Example

No response

@Nick-Hemenway Nick-Hemenway added the enhancement New feature or improvement to existing functionality label Feb 12, 2025
@zanieb
Copy link
Member

zanieb commented Feb 12, 2025

Duplicate of #11273

@zanieb zanieb marked this as a duplicate of #11273 Feb 12, 2025
@zanieb zanieb closed this as completed Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants