node-ffi-napi / weak-napi

Make weak references to JavaScript Objects.
ISC License
45 stars 4 forks source link

node-gyp cannot rebuild #22

Open jonbondani opened 4 years ago

jonbondani commented 4 years ago

Hi, I'm trying to install a nodejs project that uses weak-napi as a dependency of another package. I've tried several node, yarn, python and node-gyp versions, all with the same result:

yarn install
yarn install v1.19.1
info No lockfile found.
[1/4] šŸ”  Resolving packages...
[2/4] šŸšš  Fetching packages...
[3/4] šŸ”—  Linking dependencies...
[4/4] šŸ”Ø  Building fresh packages...
[-/7] ā¢€ waiting...
[-/7] ā¢€ waiting...
[-/7] ā¢€ waiting...
[4/7] ā¢€ weak-napi
error /Users/****/node_modules/weak-napi: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/****/node_modules/weak-napi
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.3
gyp info using node@10.17.0 | darwin | x64
gyp info find Python using Python version 2.7.10 found at "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
gyp http GET https://nodejs.org/download/release/v10.17.0/node-v10.17.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v10.17.0/node-v10.17.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v10.17.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v10.17.0/SHASUMS256.txt
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [ '/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/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/****/node_modules/weak-napi/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/Library/Caches/node-gyp/10.17.0/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/****/Library/Caches/node-gyp/10.17.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/****/Library/Caches/node-gyp/10.17.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/****/node_modules/weak-napi',
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 make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  LIBTOOL-STATIC Release/nothing.a
Traceback (most recent call last):
  File "./gyp-mac-tool", line 611, in <module>
    sys.exit(main(sys.argv[1:]))
  File "./gyp-mac-tool", line 30, in main
    exit_code = executor.Dispatch(args)
  File "./gyp-mac-tool", line 45, in Dispatch
    return getattr(self, method)(*args[1:])
  File "./gyp-mac-tool", line 248, in ExecFilterLibtool
    if not libtool_re.match(line) and not libtool_re5.match(line):
TypeError: cannot use a string pattern on a bytes-like object
make: *** [Release/nothing.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:193:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/****/.nvm/versions/node/v10.17.0/bin/node" "/Users/****/.nvm/versions/node/v10.17.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/****/node_modules/weak-napi****

I've opened an issue in the node-gyp's git as well but I think the problem is related to the weak-napi installation.

Can you help me with this issue, please? Thanks

nuthinking commented 4 years ago

Same issue here.

Arnaud73 commented 4 years ago

Same issue here on macOS X High Sierra (Node.js, yarn up to date):

error /Users/Arnaud/DeĢveloppement/78 North/performance-center/apps/node_modules/weak-napi: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments: 
Directory: /Users/Arnaud/DeĢveloppement/78 North/performance-center/apps/node_modules/weak-napi
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.5
gyp info using node@12.14.1 | darwin | x64
gyp info find Python using Python version 2.7.17 found at "/usr/local/opt/python@2/bin/python2.7"
gyp info spawn /usr/local/opt/python@2/bin/python2.7
gyp info spawn args [
gyp info spawn args   '/Users/Arnaud/.nvm/versions/node/v12.14.1/lib/node_modules/npm/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/Arnaud/DeĢveloppement/78 North/performance-center/apps/node_modules/weak-napi/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Arnaud/.nvm/versions/node/v12.14.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Arnaud/Library/Caches/node-gyp/12.14.1/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/Arnaud/Library/Caches/node-gyp/12.14.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/Arnaud/.nvm/versions/node/v12.14.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/Arnaud/Library/Caches/node-gyp/12.14.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/Arnaud/DeĢveloppement/78 North/performance-center/apps/node_modules/weak-napi',
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 make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  LIBTOOL-STATIC Release/nothing.a
  CXX(target) Release/obj.target/weakref/src/weakref.o
clang: error: no such file or directory: 'North/performance-center/apps/node_modules/node-addon-api'
make: *** [Release/obj.target/weakref/src/weakref.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/Arnaud/.nvm/versions/node/v12.14.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:223:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/Users/Arnaud/.nvm/versions/node/v12.14.1/bin/node" "/Users/Arnaud/.nvm/versions/node/v12.14.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Arnaud/DeĢveloppement/78 North/performance-center/apps/node_modules/weak-napi
Saturn-V commented 4 years ago

For folk running into this issue - a potential culprit may be an incompatible python version being invoked by node-gyp rebuild. This was the case on my machine (macOS Catalina) - python was pointing to a pyenv installed version of python (3.7.0) which yielded the error shared in this thread. switching to the system installed version (2.7.15 in my case for me) allowed the build to proceed.

Not very ideal, but seems to be an issue with python 2 vs 3. maybe the rebuild command should be updated to check for the expected python version, and throw a more helpful error when not found? not sure if that's the correct resolution, if one is necessary for this sort of error

herleraja commented 1 year ago

Instead of messing with python environments you can simply create a virtual environment and continue.

  1. Create a python virtual environment
    python3 -m venv localvenv
    source ./localvenv/bin/activate
  2. yarn install for installation of the packages.