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

python3 -> python rename has broken node-gyp #24869

Closed
chrmoritz opened this Issue Mar 5, 2018 · 9 comments

Comments

Projects
None yet
4 participants
@chrmoritz
Copy link
Contributor

chrmoritz commented Mar 5, 2018

  • are reporting a bug others will be able to reproduce and not asking a question. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh
  • have a problem with brew install (or upgrade, reinstall) a single, official formula (not cask)? If it's a general brew problem please file this issue at Homebrew/brew: https://github.com/Homebrew/brew/issues/new. If it's a brew cask problem please file this issue at https://github.com/caskroom/homebrew-cask/issues/new. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
  • if brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?

The python3 to python rename from #24604 has broken node-gyp (if you have python 3.x installed), because it expects that python (on the $PATH) to be version 2.7.x.

This will require some tweaking of the node formula to point node-gyp to our python2 formula. I will look into this soon.

How to reproduce:

$ npm install fsevents@1.1.1 --build-from-source
> fsevents@1.1.1 install /private/tmp/test/node_modules/fsevents
> node install

node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/local/Cellar/node/9.7.1/bin/node',
node-pre-gyp verb cli   '/private/tmp/test/node_modules/fsevents/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli   'install',
node-pre-gyp verb cli   '--fallback-to-build' ]
node-pre-gyp info using node-pre-gyp@0.6.33
node-pre-gyp info using node@9.7.1 | darwin | x64
node-pre-gyp verb command install []
node-pre-gyp info check checked for "/private/tmp/test/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node" (not found)
node-pre-gyp http GET https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.1/fse-v1.1.1-node-v59-darwin-x64.tar.gz
node-pre-gyp http 404 https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.1/fse-v1.1.1-node-v59-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.1/fse-v1.1.1-node-v59-darwin-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for fsevents@1.1.1 and node@9.7.1 (node-v59 ABI) (falling back to source compile with node-gyp) 
node-pre-gyp http 404 status code downloading tarball https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.1/fse-v1.1.1-node-v59-darwin-x64.tar.gz 
node-pre-gyp verb command build [ 'rebuild' ]
gyp ERR! configure error 
gyp ERR! stack Error: Python executable "/usr/local/bin/python" is v3.6.4, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
gyp ERR! stack     at PythonFinder.failPythonVersion (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:492:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:474:14)
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:265:7)
gyp ERR! stack     at ChildProcess.emit (events.js:127:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:936:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:353:11)
gyp ERR! stack     at Socket.emit (events.js:127:13)
gyp ERR! stack     at Pipe._handle.close [as _onclose] (net.js:558:12)
gyp ERR! System Darwin 17.4.0
gyp ERR! command "/usr/local/Cellar/node/9.7.1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/private/tmp/test/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node" "--module_name=fse" "--module_path=/private/tmp/test/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64"
gyp ERR! cwd /private/tmp/test/node_modules/fsevents
gyp ERR! node -v v9.7.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/9.7.1/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/private/tmp/test/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node --module_name=fse --module_path=/private/tmp/test/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/private/tmp/test/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:127:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:936:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
node-pre-gyp ERR! System Darwin 17.4.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/9.7.1/bin/node" "/private/tmp/test/node_modules/fsevents/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /private/tmp/test/node_modules/fsevents
node-pre-gyp ERR! node -v v9.7.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.33
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/Cellar/node/9.7.1/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/private/tmp/test/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node --module_name=fse --module_path=/private/tmp/test/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64' (1)
npm WARN enoent ENOENT: no such file or directory, open '/private/tmp/test/package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fsevents@1.1.1 install: `node install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the fsevents@1.1.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chrmoritz/.npm/_logs/2018-03-05T15_27_54_690Z-debug.log
$ brew doctor
Your system is ready to brew.
$ brew config                                                                                                                                                   
HOMEBREW_VERSION: 1.5.8-10-g3184d08
ORIGIN: https://github.com/Homebrew/brew
HEAD: 3184d087b99275ec1a2d0c88337c4647ebd9dd2e
Last commit: 5 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: bd37905e33a3b3ca8ba52e74c85c66377302f482
Core tap last commit: 71 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
HOMEBREW_RUBY_WARNINGS: -W0
CPU: quad-core 64-bit kabylake
Homebrew Ruby: 2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 9.0 build 900
Git: 2.16.2 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Perl: /usr/local/bin/perl => /usr/local/Cellar/perl/5.26.1/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.5.0_2/bin/ruby
Java: N/A
macOS: 10.13.3-x86_64
Xcode: 9.2
CLT: 9.2.0.0.1.1510905681
X11: N/A
@chrmoritz

This comment has been minimized.

Copy link
Contributor Author

chrmoritz commented Mar 5, 2018

A possible fix is to also set python = /usr/local/opt/python@2/bin/python2 in our npmrc. The problem is, that this file isn't picked up by yarn just yet, so yarn will be broken in the meantime, but this could be fixed in the yarn formula by setting the corresponding environment variable in our env_script.

chrmoritz added a commit to chrmoritz/homebrew-core that referenced this issue Mar 5, 2018

@chrmoritz

This comment has been minimized.

Copy link
Contributor Author

chrmoritz commented Mar 5, 2018

Possible fix in: master...chrmoritz:node-gyp

Will open a PR after conforming everything is working fine again locally.

PR: #24870

chrmoritz added a commit to chrmoritz/homebrew-core that referenced this issue Mar 5, 2018

chrmoritz added a commit to chrmoritz/homebrew-core that referenced this issue Mar 5, 2018

BrewTestBot added a commit to BrewTestBot/homebrew-core that referenced this issue Mar 5, 2018

chrmoritz added a commit to chrmoritz/homebrew-core that referenced this issue Mar 5, 2018

BrewTestBot added a commit to BrewTestBot/homebrew-core that referenced this issue Mar 5, 2018

chrmoritz added a commit to chrmoritz/homebrew-core that referenced this issue Mar 5, 2018

chrmoritz added a commit to chrmoritz/homebrew-core that referenced this issue Mar 5, 2018

BrewTestBot added a commit to BrewTestBot/homebrew-core that referenced this issue Mar 5, 2018

BrewTestBot added a commit to BrewTestBot/homebrew-core that referenced this issue Mar 5, 2018

chrmoritz added a commit to chrmoritz/homebrew-core that referenced this issue Mar 5, 2018

BrewTestBot added a commit to BrewTestBot/homebrew-core that referenced this issue Mar 5, 2018

chrmoritz added a commit to chrmoritz/homebrew-core that referenced this issue Mar 5, 2018

BrewTestBot added a commit to BrewTestBot/homebrew-core that referenced this issue Mar 5, 2018

@piouPiouM

This comment has been minimized.

Copy link

piouPiouM commented Mar 6, 2018

You can add the following line in your .bashrc or .zshrc (etc) file to fix the issue:

[ -d "/usr/local/opt/python@2/bin" ] && export PATH="/usr/local/opt/python@2/bin:$PATH"

Related issue: #24873

piouPiouM added a commit to piouPiouM/dotfiles that referenced this issue Mar 6, 2018

@chrmoritz

This comment has been minimized.

Copy link
Contributor Author

chrmoritz commented Mar 6, 2018

@piouPiouM: This would only work with node-gyp 3.5.0 or higher but not with older versions, because they fail if python in the $PATH is v3.x (and not 2.7) and your fix only adds python2 to the $PATH (which is picked up as a fallback since node-gyp 3.5.0).

Also a proper fix is ready to merge in #24913 and #24874.

chrmoritz added a commit to chrmoritz/homebrew-core that referenced this issue Mar 6, 2018

BrewTestBot added a commit to BrewTestBot/homebrew-core that referenced this issue Mar 6, 2018

@ilovezfs ilovezfs closed this in e5f7031 Mar 6, 2018

@jminz

This comment has been minimized.

Copy link

jminz commented Mar 8, 2018

brew install python2

@ronkorving

This comment has been minimized.

Copy link

ronkorving commented Mar 9, 2018

This is still an issue for me. I use NPM, not Yarn. And I use nvm (installed via homebrew). I understand there are workarounds, but should this not work out of the box?

@chrmoritz

This comment has been minimized.

Copy link
Contributor Author

chrmoritz commented Mar 9, 2018

You are right, any Node version manager is still affected by this. I will look into if we can fix this by putting a npmrc somewhere into their Cellar. If not possible, we should at least point the users to the fix echo "python = /usr/bin/python" >> ~/.npmrc in the caveats.

@ronkorving

This comment has been minimized.

Copy link

ronkorving commented Mar 9, 2018

Thanks, much appreciated :)

@chrmoritz

This comment has been minimized.

Copy link
Contributor Author

chrmoritz commented Mar 10, 2018

Should be fixed by #25060 (PEP 394, python is now python 2.7 again).

@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.