Windows build fails in error-support build script with "couldn't find Python 3 in $PATH" when no python/python3 is on PATH
Categories
(Application Services :: General, defect, P1)
Tracking
(firefox160 fixed)
| Tracking | Status | |
|---|---|---|
| firefox160 | --- | fixed |
People
(Reporter: Jamie, Assigned: janerik)
References
(Blocks 1 open bug, Regression)
Details
(Keywords: regression)
Attachments
(1 external file)
Steps to reproduce
- On Windows, have Python installed such that only the
pylauncher is onPATH, with nopython.exeorpython3.exe(other than the Microsoft Store app execution alias stubs). - Build Firefox with
py mach build.
Expected results
The build succeeds, as it did before bug 2080179 landed.
Actual results
The build fails while running the error-support build script:
Compiling error-support v0.1.0 (D:\gecko\third_party\application-services\components\support\error)
error: failed to run custom build command for `error-support v0.1.0 (D:\gecko\third_party\application-services\components\support\error)`
Caused by:
process didn't exit successfully: `D:/gecko/obj\release\build\error-support-f6bea4c2d04acabd\build-script-build` (exit code: 101)
--- stderr
got env dir: C:\Users\jamie\.mozbuild\srcdirs\gecko-23ebcb979905\_virtualenvs\build
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases.
thread 'main' (15332) panicked at third_party\application-services\components\support\error\build.rs:17:10:
Error generating Glean Rust bindings: couldn't find Python 3 in $PATH
Additional information
This started after the application-services vendor in bug 2080179, which added a build.rs to error-support that generates Glean bindings with glean-build.
Per that commit message, the error-support change came in with upstream application-services changes for the Glean error ping on iOS (bug 2011695), rather than the credit card work bug 2080179 is about.
I'm completely unfamiliar with this code, so here's a Claude assisted analysis for what it's worth, but I can't vouch for it:
- The build script is given the mach build virtualenv (the "got env dir" line), which does contain
Scripts\python.exe. - However,
xshell-venv(used byglean-build) appears to probe for a Python 3 on the existingPATHbefore it uses that virtualenv, and fails if it can't find one. - Gecko doesn't seem to enable the
glean-symorglean-fogfeatures oferror-support, so the generated bindings may not be used in Gecko builds at all.
| Reporter | ||
Comment 1•1 month ago
|
||
Likely Windows specific, since most other systems would have python or python3 on the path, whereas Windows sometimes only has py.
Comment 2•1 month ago
|
||
Mark/:chutten, who would know about the rust glean bits in app-services and xshell-venv?
Comment 3•1 month ago
|
||
error-support's build.rs is all about glean and I don't know anything about glean_build. So maybe Jan-Erik?
| Assignee | ||
Comment 4•1 month ago
|
||
Yup, I can take a look.
I don't have Windows, what's py there? The actual Python tooling or some other wrapper?
Comment 5•1 month ago
|
||
(In reply to Jan-Erik Rediger [:janerik] from comment #4)
Yup, I can take a look.
I don't have Windows, what'spythere? The actual Python tooling or some other wrapper?
--> Jamie?
| Reporter | ||
Comment 6•1 month ago
|
||
Cool, we're playing needinfo pass the parcel! :)
On Windows, the Python executable for a given version of Python is normally called python.exe. However, in order to allow different versions of Python to exist side by side without giving the executables all different names and having all the Python installations on the PATH environment variable, and in order to allow a user to choose a default Python version, Python ships with a shared py.exe "launcher" which is always on the PATH. (Symlinking executables into a global bin directory isn't really a thing on Windows.) The practical upshot is that to launch the user's default Python version, you would normally use py instead of python.
At the end of the day, according to my (rudimentary) understanding of what's going on here, this isn't actually particularly relevant to the fix because we should be using mach's Python environment anyway. Notice this in the log:
got env dir: C:\Users\jamie\.mozbuild\srcdirs\gecko-23ebcb979905\_virtualenvs\build
That is the path to the mach Python virtualenv. Inside that, we have:
C:\Users\jamie\.mozbuild\srcdirs\gecko-23ebcb979905\_virtualenvs\build\Scripts\python.exe
Unfortunately, instead of just using that Python it was given, xshell-venv probes for python on the system PATH and fails.
Interestingly, as I understand it, once it finds Python (if I put a python.exe on the PATH), it does eventually use the mach virtualenv anyway. So it's just the initial probe that's broken here.
My thinking is that if a virtualenv is specified (the "got env dir" from the log), xshell-venv should just use that, rather than trying to probe for a system Python. But again, I'm not at all familiar with the code, so I offer this only as a starting point; feel free to disregard if it's off track.
| Assignee | ||
Comment 7•1 month ago
|
||
(In reply to James Teh [:Jamie] from comment #6)
Cool, we're playing needinfo pass the parcel! :)
Oh heh, my mistake. I had intended to ni? you.
On Windows, the Python executable for a given version of Python is normally called python.exe. However, in order to allow different versions of Python to exist side by side without giving the executables all different names and having all the Python installations on the PATH environment variable, and in order to allow a user to choose a default Python version, Python ships with a shared py.exe "launcher" which is always on the PATH. (Symlinking executables into a global bin directory isn't really a thing on Windows.) The practical upshot is that to launch the user's default Python version, you would normally use py instead of python.
Thanks! So not too dissimilar to other Python version managers, just under a different name.
Interestingly, as I understand it, once it finds Python (if I put a python.exe on the PATH), it does eventually use the mach virtualenv anyway. So it's just the initial probe that's broken here.
My thinking is that if a virtualenv is specified (the "got env dir" from the log), xshell-venv should just use that, rather than trying to probe for a system Python. But again, I'm not at all familiar with the code, so I offer this only as a starting point; feel free to disregard if it's off track.
That is indeed what it should do, I'll work on a fix.
| Assignee | ||
Updated•1 month ago
|
| Assignee | ||
Comment 8•1 month ago
|
||
Comment 10•1 month ago
|
||
| bugherder | ||
Description
•