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

Executables installed via uv cannot be run from a subprocess on Windows #1612

Closed
AlexWaygood opened this issue Feb 17, 2024 · 4 comments
Closed
Labels
bug Something isn't working windows Specific to the Windows platform

Comments

@AlexWaygood
Copy link
Member

AlexWaygood commented Feb 17, 2024

Minimal repro in PowerShell:

PS C:\Users\alexw> uv venv env
Using Python 3.12.1 interpreter at C:\Users\alexw\AppData\Local\Programs\Python\Python312\python.exe
Creating virtualenv at: env
PS C:\Users\alexw> env\scripts\activate
(env) PS C:\Users\alexw> uv pip install black
Resolved 7 packages in 395ms
Downloaded 1 package in 218ms
Installed 7 packages in 106ms
 + black==24.2.0
 + click==8.1.7
 + colorama==0.4.6
 + mypy-extensions==1.0.0
 + packaging==23.2
 + pathspec==0.12.1
 + platformdirs==4.2.0
(env) PS C:\Users\alexw> python -c "import subprocess; subprocess.run(['black', 'coding/typeshed'])"
C:\Users\alexw\AppData\Local\Programs\Python\Python312\python.exe: can't open file 'C:\\Users\\alexw\\black': [Errno 2] No such file or directory

The same commands work fine if I use the stdlib venv module to create the virtual environment and I use pip to install black. Invoking black directly from the command line seems to work fine; it's only invoking it via a subprocess that doesn't seem to work.

A consequence of this bug seems to be that it's impossible to run coverage -m pytest on Windows inside a GitHub Actions workflow if you've installed coverage using uv. Here's my attempt at switching typeshed-stats to use uv:

CI is now green everywhere, except on Windows, where invoking coverage -m pytest fails with the message:

 Error: The system cannot find the file specified.
 (from CreateProcessA(null(), child_cmdline.as_mut_ptr(), null(), null(), 1, 0,
    null(), null(), addr_of!(*si), child_process_info.as_mut_ptr()))

(Running python -m coverage works, but one test in my suite still fails, because I have a test that asserts that running typeshed-stats as a standalone executable works, and I invoke the standalone executable using a subprocess for that test...)

@MichaReiser
Copy link
Member

I think that should be fixed by #1523

@AlexWaygood
Copy link
Member Author

My local repro is now fixed -- thanks! However, I'm still seeing the strange errors over at AlexWaygood/typeshed-stats#189 (which is now using uv==0.1.4). I thought those errors had the same cause as the local repro I posted above, but perhaps not.

@AlexWaygood
Copy link
Member Author

Since the original repro at the top of this issue is now fixed, I'll close this and open a new, more targeted issue

@AlexWaygood
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows Specific to the Windows platform
Projects
None yet
Development

No branches or pull requests

2 participants