question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setting cache-min to > 2^32 breaks node-gyp

See original GitHub issue

using node-gyp with some settings for cache-min crashes with an error.

I was setting cache-min to a large value, say, 9999999999 so that npm will install from the cache instead of going to the main registry, which slows down an install a lot if you have a slow internet connection, especially since most requests will just return 304 that your cached version is correct.

However, I get this error when installing a module that uses node-gyp

ValueError: Variable expansion in this context permits str and int only, found long for cache_min while trying to load binding.gyp

this just seemed like a weird error, and compilers do lots of weird things, but then I realized that my cache-min setting was larger than 2^32, although I don’t know why node-gyp would care about that, setting it to 999999999 (9 9’s) that works.

how does node-gyp use cache-min? is this a node-gyp bug or an npm bug?

full trace:

> chloridedown@1.0.22 install /home/dominic/c/scuttlebot/node_modules/chloridedown
> node-gyp rebuild

Traceback (most recent call last):
  File "/home/dominic/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "/home/dominic/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "/home/dominic/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "/home/dominic/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 514, in gyp_main
    options.duplicate_basename_check)
  File "/home/dominic/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 130, in Load
    params['parallel'], params['root_targets'])
  File "/home/dominic/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2775, in Load
    variables, includes, depth, check, True)
  File "/home/dominic/.nvm/versions/node/v5.6.0/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 "/home/dominic/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1214, in ProcessVariablesAndConditionsInDict
    variables, build_file, 'variables')
  File "/home/dominic/.nvm/versions/node/v5.6.0/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 cache_min 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 (/home/dominic/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.2.0-22-generic
gyp ERR! command "/home/dominic/.nvm/versions/node/v5.6.0/bin/node" "/home/dominic/.nvm/versions/node/v5.6.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/dominic/c/scuttlebot/node_modules/chloridedown
gyp ERR! node -v v5.6.0
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok 

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bnoordhuiscommented, Jan 9, 2017

Could you tell me how node-gyp passes its settings to gyp?

@jddxf node-gyp passes unconsumed command line arguments to gyp: https://github.com/nodejs/node-gyp/blob/v3.4.0/lib/configure.js#L140-L148

It also scans the environment for keys that start with npm_config_ at startup: https://github.com/nodejs/node-gyp/blob/v3.4.0/lib/node-gyp.js#L159-L173

0reactions
rvaggcommented, Jun 20, 2019

someone should take this up with https://github.com/refack/GYP if you want it addressed closing due to staleness

Read more comments on GitHub >

github_iconTop Results From Across the Web

Breaks with VS2019 installed · Issue #1753 · nodejs/node-gyp
I have vs2015, vs2017 and vs2019 installed, I need them for different projects so uninstalling one isn't really an option. As far as...
Read more >
A Comprehensive Guide to Fixing Node-Gyp Issues on Windows
The Windows environment makes getting node-gyp to work a less-than-stellar developer experience. Here are some troubleshooting tips I've ...
Read more >
NPM install fails with node-gyp - Stack Overflow
Option 1: Install Visual C++ Build Tools using the Default Install option. Option 2: Install Visual Studio 2015 (or modify an existing ...
Read more >
Solving common issues with node-gyp - LogRocket Blog
Many node-gyp issues are actually issues with the toolchain used for building add-on code. We'll categorize these issues to offer solutions.
Read more >
Fix broken 'node-gyp' issue for Mac OS | by Fernando De Freitas
This issue is usually caused because a node-gyp config file called common.gypi is not set up for your current Mac OS version.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found