profile
viewpoint

Ask questionsnode-gyp configure fails

Reproduce: https://github.com/nodejs/node-addon-examples/tree/master/2_function_arguments/nan

node-gyp configure -- -f cmake

Looks like has something to do with Python3, cc @cclauss

Env

  System:
    OS: Linux 4.4 Ubuntu 18.04.2 LTS (Bionic Beaver)      
    CPU: (8) x64 Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz
    Memory: 7.52 GB / 15.89 GB
    Container: Yes
    Shell: 2.7.1 - /usr/bin/fish
  Binaries:
    Node: 13.0.1 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.12.0 - /usr/local/bin/npm
  Managers:
    Apt: 1.6.10 - /usr/bin/apt
    pip3: 19.3.1 - /usr/local/bin/pip3
  Utilities:
    CMake: 3.15.3 - /usr/local/bin/cmake
    Make: 4.1 - /usr/bin/make
    GCC: 7.4.0 - /usr/bin/gcc
    Git: 2.17.1 - /usr/bin/git
    Clang: 6.0.0-1ubuntu2 - /usr/bin/clang
  Languages:
    Bash: 4.4.19 - /bin/bash
    Perl: 5.26.1 - /usr/bin/perl
    Python: 2.7.15+ - /usr/bin/python
    Python3: 3.6.8 - /usr/bin/python3

<details><summary>Verbose output (from npm or node-gyp):</summary>

gyp info it worked if it ends with ok   
gyp info using node-gyp@6.0.0
gyp info using node@13.0.1 | linux | x64
gyp info find Python using Python version 3.6.8 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'cmake',
gyp info spawn args   '-I',
gyp info spawn args   '/mnt/d/Developer/node-addon-examples/2_function_arguments/nan/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/share/.config/yarn/global/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/daniel/.cache/node-gyp/13.0.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=/home/daniel/.cache/node-gyp/13.0.1',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/share/.config/yarn/global/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/daniel/.cache/node-gyp/13.0.1/<(target_arch)/node.lib',
Traceback (most recent call last):
gyp  File "/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py", line 50, in <module>
     sys.exit(gyp.script_main())
info  File "/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1296, in ProcessVariablesAndConditionsInDict      
     build_file)
spawn args  File "/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1311, in ProcessVariablesAndConditionsInList   '--generator-output',
    ProcessVariablesAndConditionsInDict(item, phase, variables, build_file)
gyp  File "/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1296, in ProcessVariablesAndConditionsInDict       
 info spawn args   'build',
gyp info     build_file)
spawn args  File "/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1315, in ProcessVariablesAndConditionsInList   '-Goutput_dir=.'
gyp info spawn args    expanded = ExpandVariables(item, phase, variables, build_file)
 ]
  File "/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 914, in ExpandVariables
    sys.stderr.write(p_stderr)
TypeError: write() argument must be str, not bytes while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/share/.config/yarn/global/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.4.0-18362-Microsoft
gyp ERR! command "/usr/local/bin/node" "/usr/local/bin/node-gyp" "configure" "--" "-f" "cmake"
gyp ERR! cwd /mnt/d/Developer/node-addon-examples/2_function_arguments/nan
gyp ERR! node -v v13.0.1
gyp ERR! node-gyp -v v6.0.0
gyp ERR! not ok

</details>

nodejs/node-gyp

Answer questions cclauss

Fixed in #1937. Your review of that PR would help.

useful!

Related questions

Error: `gyp` failed with exit code: 1 at ChildProcess.onCpExit hot 4
gyp ERR! stack Error: `make` failed with exit code: 2 hot 2
npm install error on windows 10 hot 2
Fails on every npm install on macOS Mojave hot 2
node-gyp: EPERM: operation not permitted, read hot 2
Visual Studio finder is doing a case-sensitive path check hot 2
node-gyp rebuild failed hot 1
Node gyp build fails on node v12.1.0 hot 1
node-pre-gyp build fail error while installing with `npm install` or `npm install -d` hot 1
Is this an Issue with MACOS catalina? hot 1
gyp ERR! stack Error: `make` failed with exit code: 2 hot 1
Is this an Issue with MACOS catalina? hot 1
Is this an Issue with MACOS catalina? hot 1
Not able to build in osx 10.14.2 with java 10.0.1 hot 1
TypeError: '>=' not supported between instances of 'tuple' and 'str' hot 1
Github User Rank List