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.brew update and can still reproduce the problem?brew doctor, fixed all issues and can still reproduce the problem?brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?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 https://github.com/Homebrew/homebrew-core/pull/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 [email protected] --build-from-source
> [email protected] 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 [email protected]
node-pre-gyp info using [email protected] | 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 [email protected] and [email protected] (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! [email protected] install: `node install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
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.
Possible fix in: https://github.com/Homebrew/homebrew-core/compare/master...chrmoritz:node-gyp
Will open a PR after conforming everything is working fine again locally.
PR: #24870
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: 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.
brew install python2
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?
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.
Thanks, much appreciated :)
Should be fixed by #25060 (PEP 394, python is now python 2.7 again).
Most helpful comment
You can add the following line in your _.bashrc_ or _.zshrc_ (etc) file to fix the issue:
Related issue: #24873