unable to build in path containing spaces
Description
When launching my project I got an error from node-keytar not being able to find some directories.
It happens that node-keytar seems to be doing some sort of path sanitisation and in some case breaking the path.
error :
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/keytar/src/async.o
⠧ Preparing native dependencies: 0 / 1: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/include/node'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/src'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/openssl/config'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/openssl/openssl/include'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/uv/include'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/zlib'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/v8/include'
clang: error: no such file or directory: 'Developpement/signer/node_modules/node-addon-api'
make: *** [Release/obj.target/keytar/src/async.o] Error 1
✖ Preparing native dependencies: 0 / 1
An unhandled error has occurred inside Forge:
node-gyp failed to rebuild '/Users/guillaume/Documents/Web Developpement/signer/node_modules/keytar'.
Error: `make` failed with exit code: 2
Error: node-gyp failed to rebuild '/Users/guillaume/Documents/Web Developpement/signer/node_modules/keytar'.
Error: `make` failed with exit code: 2
at ModuleRebuilder.rebuildNodeGypModule (/Users/guillaume/Documents/Web Developpement/signer/node_modules/electron-rebuild/src/module-rebuilder.ts:186:13)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
Steps to Reproduce
- Place your project's folder inside a folder containing a
. (likeweb development) yarnyarn start
Expected behavior:
Launch the project
Actual behavior:
crash with this error :
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/keytar/src/async.o
⠧ Preparing native dependencies: 0 / 1: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/include/node'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/src'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/openssl/config'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/openssl/openssl/include'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/uv/include'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/zlib'
clang: error: no such file or directory: 'Developpement/signer/node_modules/keytar/10.1.1/deps/v8/include'
clang: error: no such file or directory: 'Developpement/signer/node_modules/node-addon-api'
make: *** [Release/obj.target/keytar/src/async.o] Error 1
✖ Preparing native dependencies: 0 / 1
An unhandled error has occurred inside Forge:
node-gyp failed to rebuild '/Users/guillaume/Documents/Web Developpement/signer/node_modules/keytar'.
Error: `make` failed with exit code: 2
Error: node-gyp failed to rebuild '/Users/guillaume/Documents/Web Developpement/signer/node_modules/keytar'.
Error: `make` failed with exit code: 2
at ModuleRebuilder.rebuildNodeGypModule (/Users/guillaume/Documents/Web Developpement/signer/node_modules/electron-rebuild/src/module-rebuilder.ts:186:13)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
Reproduces how often:
Every-time
Versions
OS : MacOS Catalina v. 10.15.7 node : 12.14.1 yarn : 1.22.10 electron : 10.1.1 node-keytar : 6.0.1 node-gyp : 7.1.2
Additional Information
Changing the folder name to something without a space fixed the error
@GuillaumeRx thanks for this report!
I did a cursory glance of the package.json file (where our scripts are located) and binding.gyp (which handles building the native module) and couldn't spot any obvious places where we were mis-handling the current path.
I'm going to mark this as help-wanted to signal that this is some low-hanging fruit for someone to reproduce locally and dig into. Simply run this command to clone the project inside a repository with a space, then try and install the dependencies (which will rebuild the native module):
$ git clone https://github.com/atom/node-keytar -- "some path/keytar"
$ npm i
Not sure if it's applicable to platforms other than macOS, but I'll add that label as I can see the same issue locally when I follow those steps.
Bumping this to indicate that #316 seems to suggest that it's also possible to encounter this on Linux
Reading into some more history about this and it seems like gyp (which node-gyp is based upon, and is a key part of the Node ecosystem for building native modules) doesn't support spaces in paths:
https://github.com/nodejs/node-gyp/issues/65 has some extra context as it feels like this isn't something that's going to be fixed upstream anytime soon, so I'd recommend the workaround in the meantime of avoiding spaces in the clone path for the project
Thank you @shiftkey for all of those informations.