Skip to content
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

node-gyp failure when building with electron when used as a dependency #179

Open
varunsrin opened this issue May 28, 2021 · 1 comment
Open

Comments

@varunsrin
Copy link

Environment:

OS: OS X Big Sur 11.3
Node: v14.17.0
NPM: 6.14.13
Yarn: 1.22.10
Electron: 12.2

Repro Steps:

  1. Set up an electron app with Webpack. You can clone Electron React Boilerplate to get started quickly.

  2. cd src/ && yarn add secp256k1 && yarn install - this installs cleanly.

  3. yarn add @opengsn/provider && yarn install - this fails with the following output:

$ node -r ../.erb/scripts/BabelRegister.js ../.erb/scripts/ElectronRebuild.js
⠇ Building modules: 0/4gyp info find Python using Python version 2.7.16 found at "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
⠏ Building modules: 0/4gyp info find Python using Python version 2.7.16 found at "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
gyp info find Python using Python version 2.7.16 found at "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/src/node_modules/keccak/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/.electron-gyp/12.0.2/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/varun/.electron-gyp/12.0.2',
gyp info spawn args   '-Dnode_gyp_dir=/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/varun/.electron-gyp/12.0.2/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/varun/src/merkle-manufactory/reader/src/node_modules/keytar',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/src/node_modules/keccak/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/.electron-gyp/12.0.2/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/varun/.electron-gyp/12.0.2',
gyp info spawn args   '-Dnode_gyp_dir=/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/varun/.electron-gyp/12.0.2/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/varun/src/merkle-manufactory/reader/src/node_modules/keytar',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/src/node_modules/keccak/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/.electron-gyp/12.0.2/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/varun/.electron-gyp/12.0.2',
gyp info spawn args   '-Dnode_gyp_dir=/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/varun/.electron-gyp/12.0.2/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/varun/src/merkle-manufactory/reader/src/node_modules/keytar',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info find Python using Python version 2.7.16 found at "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/src/node_modules/keytar/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/varun/.electron-gyp/12.0.2/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/varun/.electron-gyp/12.0.2',
gyp info spawn args   '-Dnode_gyp_dir=/Users/varun/src/merkle-manufactory/reader/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/varun/.electron-gyp/12.0.2/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/varun/src/merkle-manufactory/reader/src/node_modules/keytar',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
⠦ Building modules: 0/4gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/keytar/src/async.o
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/keytar/src/async.o
  CXX(target) Release/obj.target/keytar/src/async.o
  CXX(target) Release/obj.target/keytar/src/async.o
⠼ Building modules: 0/4rm: rm: rm: ./Release/.deps/Release/obj.target/keytar/src/async.o.d.raw./Release/.deps/Release/obj.target/keytar/src/async.o.d.raw./Release/.deps/Release/obj.target/keytar/src/async.o.d.raw: : : No such file or directory
No such file or directory
No such file or directory
make: make: make: *** [Release/obj.target/keytar/src/async.o] Error 1*** [Release/obj.target/keytar/src/async.o] Error 1*** [Release/obj.target/keytar/src/async.o] Error 1


✖ Rebuild Failed
  CXX(target) Release/obj.target/keytar/src/main.o

An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild '/Users/varun/src/merkle-manufactory/reader/src/node_modules/secp256k1'.
Error: `make` failed with exit code: 2



Error: node-gyp failed to rebuild '/Users/varun/src/merkle-manufactory/reader/src/node_modules/secp256k1'.
Error: `make` failed with exit code: 2


    at ModuleRebuilder.rebuildNodeGypModule (/Users/varun/src/merkle-manufactory/reader/node_modules/electron-rebuild/lib/src/module-rebuilder.js:193:19)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Rebuilder.rebuildModuleAt (/Users/varun/src/merkle-manufactory/reader/node_modules/electron-rebuild/lib/src/rebuild.js:190:9)
    at async Promise.all (index 289)
    at async Rebuilder.rebuild (/Users/varun/src/merkle-manufactory/reader/node_modules/electron-rebuild/lib/src/rebuild.js:148:13)
    at async /Users/varun/src/merkle-manufactory/reader/node_modules/electron-rebuild/lib/src/cli.js:146:9
child_process.js:679
    throw err;
    ^

Error: Command failed: ../node_modules/.bin/electron-rebuild --parallel --force --types prod,dev,optional --module-dir .
    at checkExecSyncError (child_process.js:640:11)
    at execSync (child_process.js:676:15)
    at Object.<anonymous> (/Users/varun/src/merkle-manufactory/reader/.erb/scripts/ElectronRebuild.js:18:3)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Module._compile (/Users/varun/src/merkle-manufactory/reader/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Object.newLoader [as .js] (/Users/varun/src/merkle-manufactory/reader/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  status: 255,
  signal: null,
  output: [ null, null, null ],
  pid: 38119,
  stdout: null,
  stderr: null
}
error Command failed with exit code 1.

Attempted Fixes:

  1. Removing node_modules had no effect
  2. Changing to node version 15 had no effect.

This has very similar symptoms to a recent issue, but their solution does not seem to work. I've also cross-posted it to OpenGSN. However it seems slightly more probable that this is an issue here, since the yarn.lock file has identical declarations whether I add secp256k1 directly or whether I include is via @opengsn/provider.

secp256k1@^4.0.1:
  version "4.0.2"
  resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.2.tgz#15dd57d0f0b9fdb54ac1fa1694f40e5e9a54f4a1"
  integrity sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==
  dependencies:
    elliptic "^6.5.2"
    node-addon-api "^2.0.0"
    node-gyp-build "^4.2.0"
@nhandelsmann
Copy link

If this is a mac machine (OSX) here is what you can do

use terminal

xcode-select --print-path
then remove installed version

sudo rm -r -f /Library/Developer/CommandLineTools
and reinstall

xcode-select --install

Then use node v14.21.3.

This works in my setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants