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

Installing into a virtualenv on Windows fails when the location changes #5445

Closed
ak-gupta opened this issue Jul 25, 2024 · 15 comments · Fixed by #5456
Closed

Installing into a virtualenv on Windows fails when the location changes #5445

ak-gupta opened this issue Jul 25, 2024 · 15 comments · Fixed by #5456
Assignees
Labels
question Asking for clarification or support

Comments

@ak-gupta
Copy link

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!

@charliermarsh
Copy link
Member

Thanks, that's an interesting one. Those are indeed aliases for one another. Let me see why it's failing...

@charliermarsh
Copy link
Member

In utils.py, can you modify the exception to include all of stdout and stderr? The directory mismatch may be the problem, but it's also just a warning and so not the immediate cause of the failure.

https://github.com/capitalone/edgetest/blob/8ac71cdb26516e2120745934febc724732ab0e8d/edgetest/utils.py#L46

@charliermarsh charliermarsh added the question Asking for clarification or support label Jul 25, 2024
@ak-gupta
Copy link
Author

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

@charliermarsh
Copy link
Member

Thanks! Just to confirm, is .edgetest\core a virtual environment?

@ak-gupta
Copy link
Author

Yes! Essentially our package creates a series of virtual environments, upgrades core dependencies to the latest available version, then runs testing to see if the current library is compatible with upgraded dependencies. For this example, we're using venv.EnvBuilder(Path.cwd() / ".edgetest" / "core", with_pip=False)

@charliermarsh
Copy link
Member

I think it needs to be python.exe.

@charliermarsh
Copy link
Member

That may not matter here though. One sec.

@charliermarsh
Copy link
Member

Ok yeah tracing the code, I think that might be the problem here.

@ak-gupta
Copy link
Author

Ah. Let me try that!

@charliermarsh
Copy link
Member

We can probably be robust to it, but can you try changing to add the .exe extension on your end?

@charliermarsh charliermarsh self-assigned this Jul 25, 2024
@ak-gupta
Copy link
Author

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

@ak-gupta
Copy link
Author

The .exe extension fixed the issue! Thank you!

@charliermarsh
Copy link
Member

Stellar. @zanieb do you think we should be robust to this? I.e., passing --python .edgetest\core\Scripts\python without the .exe suffix? (We detect that it's a "file" path, but we later fail to find the file.)

@charliermarsh
Copy link
Member

I'll just fix it, easy and will be a common footgun.

@zanieb
Copy link
Member

zanieb commented Jul 25, 2024

Seems okay to infer the .exe on Windows, yeah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants