node-pre-gyp: node-pre-gyp Appveyor build failing for Windows x86 using Node 4.4.3

I was having trouble building for Windows x86 using Node.js 4.4.3, when I noticed that the Appveyor build for node-pre-gyp itself is failing for the same reason:

ENOENT: no such file or directory in readCAFile

The failed build can be seen here:

https://ci.appveyor.com/project/Mapbox/node-pre-gyp/build/1.0.373/job/h12w3ymhbyg6ltq6#L481

The build for Windows x64 using Node 4.4.3 succeeds, however.

I see that the node-gyp command is failing, but I thought perhaps node-pre-gyp might be missing something for the setup for the 4.4.3 release.

Any thoughts as to what is missing here? Now that 4.4.3 is the LTS version, it would be great to be able to have nice precompiled binaries for it.

Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Hm, this is getting stranger.

The error is intermittent, sometimes it occurs and sometimes it does not.

I’ve only been able to reproduce it with npm test which sometimes errors like on AppVeyor (sometimes not):

Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c 
"node-pre-gyp rebuild -C c:\mb\node-pre-gyp\test\app2 --clang=1 --msvs_version=2015  --custom_include_path=../include --toolset=cpp11 --loglevel=error"
gyp ERR! configure error 
gyp ERR! stack Error: ENOENT: no such file or directory, open 'c:\mb\node-pre-gyp\test\app2\undefined'
gyp ERR! stack     at Error (native)
gyp ERR! stack     at Object.fs.openSync (fs.js:549:18)
gyp ERR! stack     at Object.fs.readFileSync (fs.js:397:15)
gyp ERR! stack     at readCAFile (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\install.js:466:15)
gyp ERR! stack     at download (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\install.js:438:22)
gyp ERR! stack     at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\install.js:185:19
gyp ERR! stack     at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\mkdirp\index.js:48:26
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 10.0.14905

If I run the same command

node bin\node-pre-gyp rebuild -C c:\mb\node-pre-gyp\test\app2 --clang=1 --msvs_version=2015  --custom_include_path=../include --toolset=cpp11 --loglevel=error

directly from the command line it always succeeds:

[node-pre-gyp-test-app2] Removing "c:\mb\node-pre-gyp\test\app2\lib\binding\Release\node-pre-gyp-test-app2"
gyp info it worked if it ends with ok
gyp info using node-gyp@3.4.0
gyp info using node@4.4.7 | win32 | ia32
gyp info ok
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  app2.cc
  win_delay_load_hook.cc
     Creating library c:\mb\node-pre-gyp\test\app2\build\Release\app2.lib and object c:\mb\node-pre-gyp\test\app2\build\Release\app2.exp
  Generating code
  Finished generating code
  app2.vcxproj -> c:\mb\node-pre-gyp\test\app2\build\Release\\app2.node
  app2.vcxproj -> c:\mb\node-pre-gyp\test\app2\build\Release\app2.pdb (Full PDB)
  Copying c:\mb\node-pre-gyp\test\app2\build\Release\/app2.node to c:/mb/node-pre-gyp/test/app2/lib/binding/Release/node-pre-gyp-test-app2/app2.node
          1 file(s) copied.

My current hunch is that the problem just occurs with the tests and not with node-pre-gyp/node-gyp/gyp per se, as mocha shells out to node-pre-gyp which shells out to pre-gyp which shells out to gyp.

I think somewhere on the way the environment gets screwed (sometimes, don’t know yet when and why) and thus results in failures.

This shelling-out structure also makes this problem a nightmare to debug: If I attach to and step through the mocha process I cannot continue to step into node-pre-gyp when it gets executed. Same if I attach to node-pre-gyp and pre-gyp gets called, and so on.

I’ve got a two step work around and I filed a bug with node-gyp.

The error we see is that the string undefined isn’t a file. I’m only seeing this on 32bit windows machines with node 4.3 and 4.4. I haven’t checked others.

The work around is to set the cafile option to a real file, I chose package.json. Then we get a second bug where even though it hasn’t found a cert in package.json it still tries to use one. So you have to disable strict-ssl. We get some warnings but it works and doesn’t seem to affect other node versions.

I added these to install phase in appveyor.yml

  # work around an issue with node-gyp v3.3.1 and node 4x
  # package.json has no certificates in it so we're cool
  # https://github.com/nodejs/node-gyp/issues/921
  - cmd: npm config set -g cafile=package.json
  - cmd: npm config set -g strict-ssl=false

Progress update

Downgrading to node-gyp@3.2.1 is not feasible as it fails with this error when building with VS 2015 Update 3 (fixed in node-gyp@3.4.0):

node-gyp\src\win_delay_load_hook.c(34): 
error C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers

If this error still occurs after npm install -g node-gyp@3.4.0 a workaround might be to manually upgrade node-gyp within npm.


Still searching where undefined is coming from …