-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Cryptic WinError
reported when subprocess execution fails with WSL path
#119646
Comments
The obvious workaround for this problem (make the Windows venv on a native Windows drive instead of making it inside WSL) works, but it's genuinely unclear to me why the UNC path doesn't work. Initially I thought it might be symlink-or-copy confusion due to the mixture of filesystems (similar to tox-dev/tox#1706 ), but adding the |
This is probably an entire area of posixmodule that needs testing. The protocol used for cross-container files is P9, rather than SMB, and there's going to be a ton of stuff that isn't implemented [the same] and will need different handling. Most tellingly, failure codes will likely be different. Personally I run two separate clones, but remote the WSL one to the Windows one. But then I only ever jump in for testing and not dev work, so it makes sense to edit in Windows, commit, then
As it should, really. No paths are going to be remapped correctly (check I'm not sure the best way to handle it, but perhaps we ought to be trying to detect this scenario and fail with a helpful error? Possibly looking for |
Looking for I haven't tried yet to see if mapping the WSL folder to a drive letter would be enough to make it work (from what you wrote above, I'm guessing it may still not work, but it seems worth trying anyway). (Edit: see experiment below. As predicted, the drive mapping didn't make any difference)
Yeah, that's good advice, so I'll do that in the future (albeit the other way around, using Fedora WSL as my main dev env and testing on Windows via a local |
I just noticed the copy-and-paste of the PowerShell output had added a whole lot of spaces between the last command and its output, rather than a line break. This made it look fine in the edit widow, but thoroughly misleading when rendered (the last command with the full path failed the same way the one with the relative path did, but the incorrect formatting made it look like it had worked). This prompted me to investigate the "failure" more closely, and the
Running Python from the
The error apparently happens later in the
vs a native Windows venv:
|
Huh, looks like it might be
Running
|
@zooba The idea of detect-and-report-a-useful-error is sounding good to me, but based on the above that detect-and-error for |
Just experimentally confirming what @zooba wrote above, that the problem here is with attempting to run a Windows binary from a WSL folder via
It's apparently possible for this to work, since PowerShell itself manages to launch the binary from its thoroughly dubious WSL location, but |
Another option that occurs to me is that rather than trying to detect anything WSL specific, we could potentially intercept the |
This sounds like a good option. Knowing that It would be interesting to see if |
|
Thanks. I suspect that means we can't do anything about it other than detect and fail-fast. |
WinError
reported when subprocess execution fails with WSL path
Based on the investigation below, the most pragmatic change we can make here is to enhance the exception handling around the
_winapi.CreateProcess
call insubprocess
such that the reportedWinError
that is raised when the command given is on a WSL path at least reports the offending command (the wayos.startfile
already does).Original bug report
ensurepip fails on Windows venv creation with WSL UNC path
Bug description:
Running Python 3.12.3 from the Windows Store via Windows PowerShell, attempting to create a Windows virtual environment under a WSL UNC path fails:
(I initially thought this might be related to #102584 , as it has some similarities to #102496, but there were enough differences that it seemed worthwhile to file a dedicated issue. The investigation below strongly supports the idea that this is a different problem, specifically with
ensurepip
trying to invoke a subprocess whensys.executable
is pointing at an executable stored in a WSL folder)CPython versions tested on:
3.12
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: