Closed Bug 2082730 Opened 1 month ago Closed 1 month ago

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)

Desktop
Windows

Tracking

(firefox160 fixed)

RESOLVED FIXED
160 Branch
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

  1. On Windows, have Python installed such that only the py launcher is on PATH, with no python.exe or python3.exe (other than the Microsoft Store app execution alias stubs).
  2. 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 by glean-build) appears to probe for a Python 3 on the existing PATH before it uses that virtualenv, and fails if it can't find one.
  • Gecko doesn't seem to enable the glean-sym or glean-fog features of error-support, so the generated bindings may not be used in Gecko builds at all.

Likely Windows specific, since most other systems would have python or python3 on the path, whereas Windows sometimes only has py.

OS: Unspecified → Windows
Hardware: Unspecified → Desktop

Mark/:chutten, who would know about the rust glean bits in app-services and xshell-venv?

Flags: needinfo?(markh)
Flags: needinfo?(chutten)

error-support's build.rs is all about glean and I don't know anything about glean_build. So maybe Jan-Erik?

Flags: needinfo?(markh) → needinfo?(jrediger)

Yup, I can take a look.
I don't have Windows, what's py there? The actual Python tooling or some other wrapper?

Flags: needinfo?(jrediger)
Flags: needinfo?(chutten)

(In reply to Jan-Erik Rediger [:janerik] from comment #4)

Yup, I can take a look.
I don't have Windows, what's py there? The actual Python tooling or some other wrapper?

--> Jamie?

Flags: needinfo?(jteh)

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.

Flags: needinfo?(jteh)

(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: nobody → jrediger
Status: NEW → ASSIGNED
Priority: -- → P1
Pushed by jrediger@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/73d2a1c16593 https://hg.mozilla.org/integration/autoland/rev/90d88219c87f Update xshell-venv with a fix to properly reuse defined venvs r=TravisLong,supply-chain-reviewers
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: