Yarn: failed to install node-hid on arm linux (failed to execute node-gyp)

Created on 19 Dec 2016  Â·  19Comments  Â·  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
bug

What is the current behavior?

pi@raspberrypi:~/tmp $ yarn add node-hid                                                                                                                                            
yarn add v0.18.1                                                                                                                                                                    
info No lockfile found.                                                                                                                                                             
[1/4] Resolving packages...                                                                                                                                                         
[2/4] Fetching packages...                                                                                                                                                          
[3/4] Linking dependencies...                                                                                                                                                       
[4/4] Building fresh packages...                                                                                                                                                    
[1/1] â¡€ node-hid: node-pre-gyp                                                                                                                                                      
[-/1] â¡€ waiting...                                                                                                                                                                  
[-/1] â¡€ waiting...                                                                                                                                                                  
[-/1] â¡€ waiting...                                                                                                                                                                  
error /home/pi/tmp/node_modules/node-hid: Command failed.                                                                                                                           
Exit code: 1                                                                                                                                                                        
Command: sh                                                                                                                                                                         
Arguments: -c node-pre-gyp install --fallback-to-build                                                                                                                              
Directory: /home/pi/tmp/node_modules/node-hid                                                                                                                                       
Output:                                                                                                                                                                             
node-pre-gyp info it worked if it ends with ok                                                                                                                                      
node-pre-gyp info using [email protected]                                                                                                                                         
node-pre-gyp info using [email protected] | linux | arm                                                                                                                                    
node-pre-gyp info check checked for "/home/pi/tmp/node_modules/node-hid/build/HID/Release/HID.node" (not found)                                                                     
node-pre-gyp http GET https://github.com/node-hid/node-hid/releases/download/0.5.2/HID-v0.5.2-node-v51-linux-arm.tar.gz                                                             
node-pre-gyp http 404 https://github.com/node-hid/node-hid/releases/download/0.5.2/HID-v0.5.2-node-v51-linux-arm.tar.gz                                                             
node-pre-gyp ERR! Tried to download(404): https://github.com/node-hid/node-hid/releases/download/0.5.2/HID-v0.5.2-node-v51-linux-arm.tar.gz                                         
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v51 ABI) (falling back to source compile with node-gyp)                                      
node-pre-gyp http 404 status code downloading tarball https://github.com/node-hid/node-hid/releases/download/0.5.2/HID-v0.5.2-node-v51-linux-arm.tar.gz                             
gyp info it worked if it ends with ok                                                                                                                                               
gyp info using [email protected]                                                                                                                                                       
gyp info using [email protected] | linux | arm                                                                                                                                             
gyp info ok                                                                                                                                                                         
gyp info it worked if it ends with ok                                                                                                                                               
gyp info using [email protected]                                                                                                                                                       
gyp info using [email protected] | linux | arm                                                                                                                                             
gyp info spawn /usr/bin/python2                                                                                                                                                     
gyp info spawn args [ '/usr/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   '/home/pi/tmp/node_modules/node-hid/build/config.gypi',                                                                                                       
gyp info spawn args   '-I',                                                                                                                                                         
gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',                                                                                                 
gyp info spawn args   '-I',                                                                                                                                                         
gyp info spawn args   '/home/pi/.node-gyp/7.2.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/pi/.node-gyp/7.2.1',                                                                                                                   
gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',                                                                                             
gyp info spawn args   '-Dnode_lib_file=node.lib',                                                                                                                                   
gyp info spawn args   '-Dmodule_root_dir=/home/pi/tmp/node_modules/node-hid',                                                                                                       
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=.' ]                                                                                                                                            
Traceback (most recent call last):                                                                                                                                                  
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>                                                                                      
    sys.exit(gyp.script_main())                                                                                                                                                     
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main                                                                        
    return main(sys.argv[1:])                                                                                                                                                       
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main                                                                               
    return gyp_main(args)                                                                                                                                                           
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 514, in gyp_main                                                                           
    options.duplicate_basename_check)                                                                                                                                               
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 130, in Load                                                                               
    params['parallel'], params['root_targets'])                                                                                                                                     
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2775, in Load                                                                                 
    variables, includes, depth, check, True)                                                                                                                                        
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 417, in LoadTargetBuildFile                                                                   
    build_file_data, PHASE_EARLY, variables, build_file_path)                                                                                                                       
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1214, in ProcessVariablesAndConditionsInDict                                                  
    variables, build_file, 'variables')                                                                                                                                             
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1225, in ProcessVariablesAndConditionsInDict                                                  
    'only, found ' + expanded.__class__.__name__ + ' for ' + key)                                                                                                                   
ValueError: Variable expansion in this context permits str and int only, found long for lastUpdateCheck 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/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)                                                               
gyp ERR! stack     at emitTwo (events.js:106:13)                                                                                                                                    
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)                                                                                                                           
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)                                                                                        
gyp ERR! System Linux 4.4.13-v7+                                                                                                                                                    
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/pi/tmp/node_modules/node-hid/
build/HID/Release/HID.node" "--module_name=HID" "--module_path=/home/pi/tmp/node_modules/node-hid/build/HID/Release"                                                                
gyp ERR! cwd /home/pi/tmp/node_modules/node-hid                                                                                                                                     
gyp ERR! node -v v7.2.1                                                                                                                                                             
gyp ERR! node-gyp -v v3.4.0                                                                                                                                                         
gyp ERR! not ok                                                                                                                                                                     
node-pre-gyp ERR! build error                                                                                                                                                       
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/pi/tm
p/node_modules/node-hid/build/HID/Release/HID.node --module_name=HID --module_path=/home/pi/tmp/node_modules/node-hid/build/HID/Release' (1)                                        
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/pi/tmp/node_modules/node-hid/node_modules/node-pre-gyp/lib/util/compile.js:83:29)                                    
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)                                                                                                                           
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)                                                                                                                  
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:885:16)                                                                                                        
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)                                                                                
node-pre-gyp ERR! System Linux 4.4.13-v7+                                                                                                                                           
node-pre-gyp ERR! command "/usr/bin/nodejs" "/home/pi/tmp/node_modules/node-hid/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"                                     
node-pre-gyp ERR! cwd /home/pi/tmp/node_modules/node-hid                                                                                                                            
node-pre-gyp ERR! node -v v7.2.1                                                                                                                                                    
node-pre-gyp ERR! node-pre-gyp -v v0.6.31                                                                                                                                           
node-pre-gyp ERR! not ok                                                                                                                                                            
Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/pi/tmp/node_modules/node-hid/build/H
ID/Release/HID.node --module_name=HID --module_path=/home/pi/tmp/node_modules/node-hid/build/HID/Release' (1)                                                                       
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.                                                                                                
pi@raspberrypi:~/tmp $                                                                                                                                                              

Please mention your node.js, yarn and operating system version.

  • Rapsbian on Raspberry pi 3
  • yarn 0.18.1
  • node 7.2.1
cat-bug

Most helpful comment

worked for me

--- /node_modules/node-gyp/gyp/pylib/gyp/input.py  2017-01-03 00:49:06.045760000 +0300
+++ /node_modules/node-gyp/gyp/pylib/gyp/input.py       2017-01-03 00:49:04.140838600 +0300
@@ -1219,6 +1219,8 @@
     # Skip "variables", which was already processed if present.
     if key != 'variables' and type(value) is str:
       expanded = ExpandVariables(value, phase, variables, build_file)
+      if type(expanded) in (long, list, dict):
+        continue
       if type(expanded) not in (str, int):
         raise ValueError(
               'Variable expansion in this context permits str and int ' + \
$ node --version
v6.9.2
$ yarn --version
0.18.1

All 19 comments

npm install node-hid works

I can confirm that I'm experiencing the same behaviour but when attempting to install bcrypt.

Yarn v0.18.1 (MSI installation)
Node v6.9.2
OS Windows Server 2012.

Same behavior on Windows 10 x64 with Node 6.9.1 when building nslog.

~This worked fine on yarn v0.17.10 before I updated to v0.18.1. But for some reason, I can't get it to work at all now even if I install the older version via npm (after uninstalling yarn and running npm cache clean).~

Update: Deleting the ".yarnrc" file in my user home directory fixed it. This works with v0.17.10 again.

Same thing with v0.18.1 (Debian Jessie, ARM, Node v6.9.1) when installing node-expat

pi@raspberrypi:~/project-name $ yarn add node-expat
yarn add v0.18.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/2] â „ electron
[2/2] â „ node-expat: not ok
[-/2] â¡€ waiting...
[-/2] â¡€ waiting...
error /home/pi/project-name/node_modules/node-expat: Command failed.
Exit code: 1
Command: sh
Arguments: -c node-gyp rebuild
Directory: /home/pi/project-name/node_modules/node-expat
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | arm
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/lib/node_modules/yarn/updates/0.18.1/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   '/home/pi/project-name/node_modules/node-expat/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/pi/.node-gyp/6.9.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/pi/.node-gyp/6.9.1',
gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/pi/project-name/node_modules/node-expat',
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=.' ]
Traceback (most recent call last):
  File "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 514, in gyp_main
    options.duplicate_basename_check)
  File "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 130, in Load
    params['parallel'], params['root_targets'])
  File "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2775, in Load
    variables, includes, depth, check, True)
  File "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 417, in LoadTargetBuildFile
    build_file_data, PHASE_EARLY, variables, build_file_path)
  File "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1214, in ProcessVariablesAndConditionsInDict
    variables, build_file, 'variables')
  File "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1225, in ProcessVariablesAndConditionsInDict
    'only, found ' + expanded.__class__.__name__ + ' for ' + key)
ValueError: Variable expansion in this context permits str and int only, found long for lastUpdateCheck 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/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.32-v7+
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/yarn/updates/0.18.1/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/project-name/node_modules/node-expat
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok

Having the same issue on Windows 10 trying to install sharp. Works fine with npm, but breaks with yarn. Same error: Variable expansion in this context permits str and int only, found long for lastUpdateCheck while trying to load binding.gyp. Using msvs_version=2015.

worked for me

--- /node_modules/node-gyp/gyp/pylib/gyp/input.py  2017-01-03 00:49:06.045760000 +0300
+++ /node_modules/node-gyp/gyp/pylib/gyp/input.py       2017-01-03 00:49:04.140838600 +0300
@@ -1219,6 +1219,8 @@
     # Skip "variables", which was already processed if present.
     if key != 'variables' and type(value) is str:
       expanded = ExpandVariables(value, phase, variables, build_file)
+      if type(expanded) in (long, list, dict):
+        continue
       if type(expanded) not in (str, int):
         raise ValueError(
               'Variable expansion in this context permits str and int ' + \
$ node --version
v6.9.2
$ yarn --version
0.18.1

@vany-egorov Great to know that! Just wondering, is the module working at the end? If so, would you like to make a pull request? Thanks.

Applying @vany-egorov's fix to my local installation fixed the error for me (node v7.3.0, yarn v0.18.1)

pull request for node-gyp:
https://github.com/nodejs/node-gyp/pull/1085

@yxliang01 yep, everything works like a charm.

$ yarn
yarn install v0.18.1
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 106.54s.

This will happen with npm if there is an npm config like foobar=1111111111111.It is actually a bug of gyp, which node-gyp bundles.PR sent to node-gyp might not be accepted.But sending a PR to gyp seems quite inconvenient.See nodejs/node-gyp#903 for more information.

Any idea if we can patch it in Yarn somehow?

On 8 January 2017 at 14:46, jddxf notifications@github.com wrote:

This will happen with npm if there is an npm config like
foobar=1111111111111.It is actually a bug of gyp, which node-gyp bundles.PR
sent to node-gyp might not be accepted.But sending a PR to gyp seems quite
inconvenient.See nodejs/node-gyp#903
https://github.com/nodejs/node-gyp/issues/903 for more information.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/yarnpkg/yarn/issues/2286#issuecomment-271155407, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACBdWEpCkz1hFXte977kptbiKdH0MwzOks5rQPa8gaJpZM4LQST5
.

Here's an ugly hack:store the value of lastUpdateCheck with some prefix such as "_" to force it being a string value.

Yeah a bit ugly :)
Maybe blacklist some configs that should not be passed to node-gyp, i.e. treat them as internal

I just hit this issue too on a small IA32 VM, which has no prebuilt binaries in npm.

Indeed, blacklisting (or whitelisting) seems like the cleanest way forward…

Yeah.That would be nice if we can avoid passing them.

PR welcome :)

I'd love to give a try.

Can confirm that #2452 fixes this. If you need it urgently, you can install the latest nightly to get your installs working again: https://yarnpkg.com/en/docs/nightly

Fixed in v0.20.0, thanks!

Was this page helpful?
0 / 5 - 0 ratings