-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
uv add and uv sync doesn't install packages in virtual env created by uv venv <custom venv name> but creates the default .venv #8878
Comments
Same issue when using uv venv venv
source venv/bin/activate
uv sync Output of the last command:
|
The documentation says that |
The top-level project commands ( |
I see. It might be intentional, but it's currently blocking the adoption of uv in a project, because all existing documentation and CI pipelines assume In the meantime, is there a way to set the project environment in pyproject.toml? |
No, we don't expose it in the |
@charliermarsh I'm curious why was it decided not to honour that variable? It's a pretty standard solution, and it's a common practice to manage the environment separately from the packaging and dependency management. |
We honor it in |
OK, fair enough, I understand the decision. I'm not sure yet whether I agree with it, but I'll try playing with uv without an active environment and decide based on how much that affects my workflow (having to put The only other thing I can think of might be to include a configuration option to prevent running a command if there is an activated environment (or at least to add a confirmation prompt, instead of just a warning); I'd prefer to have some control when an environment is created. |
No we're not planning on adding it to the
Why does the virtual environment need to be discoverable at a hard-coded path? Just want to try to understand the use-case.
You can definitely activate the environment still.
Does |
Oh, of course; it's just that in my case a couple of uv's idiosyncracies collide with my usual setup. But as I said, I can think of a few workarounds; I'll know more when I try them. |
Hi @zanieb, I also tried setting the |
We have a very heavy Makefile that has targets for a lot of jobs such as creating a virtual environment, execute tests, etc. That Makefile predates tools like uv and is used in multiple projects to unify the workflows. As such
I don't control the developers environment variables, so I cannot assume that variable to be set. I can try to pull it into our Makefile, but rooting this to pyproject.toml would have been the easier choice. |
It is also really annoying because I cannot use uv add with pycharm or with different Python versions. |
@amanchaudhary-95 I get it to work by setting the |
pycharm just added official support for uv and it sucks because there is no way to choose where files are installed. (Poetry support sucks as well, but a bit differently) |
We now support a (But we won't detect inactive environments with arbitrary names and won't detect active environments by default. See #11273 for a non-CLI option) |
Current uv version: uv 0.4.29 (85f9a0d 2024-10-30)
OS: Windows 11
I created a project using
uv init
and then created a venv with the name "Temp_Venv" inside that project usinguv venv Temp_Venv
, the environment was created perfectly. After that, I activated the newly created environment and tried to add python package usinguv add pandas
, it did not install the package in the activated environment instead it created a new environment with the name .venv and installed the package in that environment. It does the same even after setting theVIRTUAL_ENV=D:\Test\Test_Venv\Temp_Venv
.Steps to reproduce:
Step 1: Init a Project with
uv init Test_Venv
Step 2: Change the directory and create a venv with a custom name of 'Temp_Venv' in that project
cd .\Test_Venv\
uv venv Temp_Venv
Step 3: Activate the newly created venv
.\Temp_Venv\Scripts\activate
Step 4: Add a package using uv add
uv add pandas
It will give a warning
warning: `VIRTUAL_ENV=Temp_Venv` does not match the project environment path `.venv` and will be ignored
and it will create a new venv with a default name .venv and it will add the package in this .venv env and not in the activated
Temp_Venv
I also tried to set the
VIRTUAL_ENV
path but still got the same resultScreenshot:

The text was updated successfully, but these errors were encountered: