Closed Bug 1600720 Opened 5 years ago Closed 5 years ago

./mach build does not work on MacOS 10.15 due to Python 3 errors

Categories

(Firefox Build System :: General, defect, P1)

Desktop
macOS
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mtigley, Assigned: mars)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Building Firefox using ./mach build is giving the following error log:

DEBUG: python2: running with pid 33720
DEBUG: python2: sys.executable: '/Users/mtigley/firefox/gecko-dev/objdir-frontend/_virtualenvs/init/bin/python'
DEBUG: python2: executable from configuration: None
DEBUG: python2: found executable: '/Users/mtigley/firefox/gecko-dev/objdir-frontend/_virtualenvs/init/bin/python'
DEBUG: python2: venv is up to date
INFO: Adding configure options from /Users/mtigley/firefox/gecko-dev/mozconfig
INFO:   --enable-artifact-builds
INFO:   --enable-debug-js-modules
INFO: checking for Python 3... 
DEBUG: python3: running with pid 33720
DEBUG: python3: sys.executable: '/Users/mtigley/firefox/gecko-dev/objdir-frontend/_virtualenvs/init/bin/python'
DEBUG: python3: executable from configuration: None
DEBUG: python3: found executable: u'/Applications/Xcode.app/Contents/Developer/usr/bin/python3'
DEBUG: python3: using venv: u'/Users/mtigley/firefox/gecko-dev/objdir-frontend/_virtualenvs/init_py3'
INFO: Creating Python 3 environment
INFO: /Users/mtigley/firefox/gecko-dev/third_party/python/virtualenv/virtualenv.py:1047: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
INFO:   import imp
INFO: Using base prefix '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7'
INFO: New python executable in /Users/mtigley/firefox/gecko-dev/objdir-frontend/_virtualenvs/init_py3/bin/python3
INFO: Also creating executable in /Users/mtigley/firefox/gecko-dev/objdir-frontend/_virtualenvs/init_py3/bin/python
INFO: Traceback (most recent call last):
INFO:   File "/Users/mtigley/firefox/gecko-dev/third_party/python/virtualenv/virtualenv.py", line 2349, in <module>
INFO:     main()
INFO:   File "/Users/mtigley/firefox/gecko-dev/third_party/python/virtualenv/virtualenv.py", line 712, in main
INFO:     symlink=options.symlink)
INFO:   File "/Users/mtigley/firefox/gecko-dev/third_party/python/virtualenv/virtualenv.py", line 927, in create_environment
INFO:     site_packages=site_packages, clear=clear, symlink=symlink))
INFO:   File "/Users/mtigley/firefox/gecko-dev/third_party/python/virtualenv/virtualenv.py", line 1342, in install_python
INFO:     shutil.copy(original_python, py_executable)
INFO: UnboundLocalError: local variable 'original_python' referenced before assignment

I have pulled the latest updates from central and have tried deleting objdir and running the build command again. But it results in the same error.

:mars, is this related to a recent change of yours?

Flags: needinfo?(mars)

Micah:

can you try ./mach clobber --full and then try again

If that fails:
delete your object directory (again) and then find . -wholename "*/__pycache__/*" -o -name "*.pyc" -o -name "*.pyo" -delete

And then try again.

I suspect this is related to https://bugzilla.mozilla.org/show_bug.cgi?id=1590745

Flags: needinfo?(mtigley)

can you try ./mach clobber --full and then try again

If that fails:
delete your object directory (again) and then find . -wholename "*/__pycache__/*" -o -name "*.pyc" -o -name "*.pyo" -delete

And then try again.

Neither of those worked, unfortunately. I am also getting the same error for both.

If it helps, this is what my mozconfig looks like:

# Automatically download and use compiled C++ components:
ac_add_options --enable-artifact-builds

# Write build artifacts to:
mk_add_options MOZ_OBJDIR=./objdir-frontend

# Enable React errors
ac_add_options --enable-debug-js-modules

Flags: needinfo?(mtigley)

Looking at the code there's an execution path where that variable gets used without assignment when we find a python installation at an unexpected path. That passage wasn't added in bug 1590745, but we seem to be hitting it as a result of that change.

This looks like a dupe of bug 1596422 which affected mach lint. Now it's affecting mach build because mach build is setting up a Python 3 virtualenv as of bug 1590745.

We don't have a workaround for this. The fix is in patches for bug 1464038 but they need work before they can land.

I think we need to find a way to fix this. Breaking mach lint on Mac OS 10.15 was bad but not a blocker. Breaking mach build for everyone on Mac OS 10.15 is bad.

We could try backing out the $PYTHON3 venv change. Some code has already landed that uses it but I don't think it's in the mach build codepath. It would need an experiment to find out.
We could try changing the init.configure code and make $PYTHON3 into a plain old variable again. Skip venv creation entirely but leave the code there until bug 1464038 lands.
We could try completing and landing the patches to update our outdated virtualenv libraries and fix Mac OS 10.15. But that could break the build further.

:chmanchester what do you think?

Flags: needinfo?(mars) → needinfo?(cmanchester)

You're correct that we can't break the build on macOS 10.15. If we can confirm that's the effect of the change and we don't have a solution we're confident in that's imminent we need to back out. There was a merge this morning, so we may need to uplift the backout as well.

Flags: needinfo?(cmanchester)
Priority: -- → P1

So there is a workaround available: use Homebrew to install Python 3 and set $PATH so that /usr/local/bin appears first.

The debug log from the bug reporter shows:

DEBUG: python3: found executable: u'/Applications/Xcode.app/Contents/Developer/usr/bin/python3'

The debug log from a Homebrew user with a modified $PATH on Mac OS 10.15 who is not affected by this bug shows:

DEBUG: python3: found executable: u’/usr/local/bin/python3'

:mtigley does that workaround work for you?

Flags: needinfo?(mtigley)

(In reply to Māris Fogels [:mars] (please needinfo) from comment #7)

So there is a workaround available: use Homebrew to install Python 3 and set $PATH so that /usr/local/bin appears first.

The debug log from the bug reporter shows:

DEBUG: python3: found executable: u'/Applications/Xcode.app/Contents/Developer/usr/bin/python3'

The debug log from a Homebrew user with a modified $PATH on Mac OS 10.15 who is not affected by this bug shows:

DEBUG: python3: found executable: u’/usr/local/bin/python3'

:mtigley does that workaround work for you?

Yes, this worked for me. I'm now able to run ./mach build without issue :)

Thank you!

Flags: needinfo?(mtigley)

We are working on a fix for this. We'll try to update virtualenv first (bug 1464038) and if that can't be done in good time we'll back out bug 1590745 .

Blocks: mach-busted
Depends on: 1464038
Regressed by: 1590745
Summary: ./mach build does not work due to Python 3 errors → ./mach build does not work on MacOS 10.15 due to Python 3 errors
Assignee: nobody → mars

Bug 1590745 has been backed out from central. Building should be possible again.

I'm going to close this bug as FIXED with the backout. Please re-open and needinfo if the bug reappears.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.