uv: Installing into a virtualenv on Windows fails when the location changes

Hi there!

uv is awesome, but we’re running into an issue with installing into a virtualenv on Windows. If I run

uv pip install --python=/path/to/python

I sometimes get an error message similar to the following:

RuntimeError: Unable to run the following command: 

 uv pip install --python=C:\Users\RUNNER~1\AppData\Local\Temp\tmp3hg_0oka\.edgetest\core\Scripts\python .[tests]
WARNING  venv:__init__.py:165 Actual environment location may have moved due to redirects, links or junctions.
  Requested location: "C:\Users\RUNNER~1\AppData\Local\Temp\tmp3hg_0oka\.edgetest\lower_env\Scripts\python.exe"
  Actual location:    "C:\Users\runneradmin\AppData\Local\Temp\tmp3hg_0oka\.edgetest\lower_env\Scripts\python.exe"

this is running on GitHub Actions using windows-latest and uv version 0.2.28. If curious, the error log is in the job from this PR. Any help is greatly appreciated!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Yep, I’ll push up a change and see if that fixes the issue

That may not matter here though. One sec.

Thanks for the quick reply! I updated the logging and got this output:

WARNING  venv:__init__.py:158 Actual environment location may have moved due to redirects, links or junctions.
  Requested location: "C:\Users\RUNNER~1\AppData\Local\Temp\tmp3l_vmwg8\.edgetest\core\Scripts\python.exe"
  Actual location:    "C:\Users\runneradmin\AppData\Local\Temp\tmp3l_vmwg8\.edgetest\core\Scripts\python.exe"
ERROR    edgetest.core:core.py:178 Unable to install the local package into core
Traceback (most recent call last):
  File "D:\a\edgetest\edgetest\edgetest\core.py", line 171, in setup
    _run_command(
  File "D:\a\edgetest\edgetest\edgetest\utils.py", line 46, in _run_command
    raise RuntimeError(
RuntimeError: Unable to run the following command: 

 uv pip install --python=C:\Users\RUNNER~1\AppData\Local\Temp\tmp3l_vmwg8\.edgetest\core\Scripts\python .[tests] 

Returned the following stdout: 

  

Returned the following stderr: 

 error: No virtual or system environment found for path `.edgetest\core\Scripts\python`

Just to note – our current code uses pip with commands equivalent to

C:\Users\RUNNER~1\AppData\Local\Temp\tmp3l_vmwg8\.edgetest\core\Scripts\python -m pip install .[tests]

since I haven’t changed the logic for finding the virtual environment