node-gyp: Build failure when builddir contains spaces.

See also: brianmcd/contextify#30.

For example, a home directory of Brad Old causes the build to fail:

> contextify@0.1.2 install /Users/Brad Old/Desktop/DEMO_jason/node_modules/d3/node_modules/jsdom/node_modules/contextify
> node-gyp rebuild

info it worked if it ends with ok 
info downloading: http://nodejs.org/dist/v0.6.17/node-v0.6.17.tar.gz 
spawn python [ '/Users/Brad Old/.node-gyp/0.6.17/tools/gyp_addon',
  'binding.gyp',
  '-I/Users/Brad Old/Desktop/DEMO_jason/node_modules/d3/node_modules/jsdom/node_modules/contextify/build/config.gypi',
  '-f',
  'make' ]
spawn make [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/contextify/src/contextify.o
clang: error: no such file or directory: 'Old/.node-gyp/0.6.17/src'
clang: error: no such file or directory: 'Old/.node-gyp/0.6.17/deps/uv/include'
clang: error: no such file or directory: 'Old/.node-gyp/0.6.17/deps/v8/include'
make: *** [Release/obj.target/contextify/src/contextify.o] Error 1
ERR! Error: `make` failed with exit code: 2
    at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
    at ChildProcess.emit (events.js:70:17)
    at maybeExit (child_process.js:362:16)
    at Process.onexit (child_process.js:398:5)
ERR! not ok
npm WARN optional dependency failed, continuing contextify@0.1.2

Notice the -I parameter is not escaped.

About this issue

  • Original URL
  • State: closed
  • Created 12 years ago
  • Reactions: 10
  • Comments: 48 (9 by maintainers)

Commits related to this issue

Most upvoted comments

^ Rude.

Closing. It’s been discussed in other issues and it’s not going to change; gyp itself doesn’t support blanks in paths.

Yes, this is still a problem, hacking with SYMLINK doesn’t seem like a good solution.

If you are using MacOS and your username contains space, such as: /Users/abc 1, I fix with:

  1. Create a link file without space
sudo ln -s /Users/abc\ 1 /Users/abc
  1. specify HOME env to install
HOME=/Users/abc npm install

As a workaround, set your HOME env variable to something that doesn’t contain spaces.

By the way, I created a PR for this last year but it hasn’t seen any movement: #2556

It looks so easy to fix.

In the last 6 months I visited this issue twice. So I documented the workaround that works for me.

My issue is that I have a hard-drive with the name Data HD. And perhaps installing globally will work in most cases but not in mine.

To fix this: first create a symlink from your hard-drive-with-a-space-in-the-name

cd /Volumes/
ln -s 'Data HD' DataHD

The check your $HOME path:

echo $HOME
/Volumes/Data HD/Users/matthijs

Change $HOME (temporary?):

HOME=/Volumes/DataHD/Users/matthijs
export HOME
echo $HOME

Now use npm install and everything should work.

After you Quit the terminal, everything is set back to the original $HOME

Hope this saves someone time in the future

This seems like it should “simply” be a matter of finding an unquoted variable replacement in a shell command somewhere… It’s been an issue for 3 years now…

👍 Not just a Windows issue: I’m trying to install an Atom plug-in that uses node-gyp as a dependency, and my ~/.atom is stored on my cloud, by symlinking it to my “Google Drive” folder. I can’t exactly rename that folder to not have a space, as it’s tied into Google Drive’s software…

Seems like this is a case for delimiting strings using a null character rather that splitting at spaces, kind of like find . -print0 | xargs -0 ... does, no?

Bump I guess? This still is an issue afaik.

Can we have a GitHub Action that fails which demonstrates this problem? Which pull request should be reviewed?

The rabbit hole goes even deeper because not all tools that gyp calls out to handle them either.

Still an issue on Mac OS X 10.9.5.

Any progress on this?

yep, still an issue:

clang: error: no such file or directory: 'HD'
clang: error: no such file or directory: '2/Projects/bla/code/bla.js/node_modules/libxslt/node_modules/libxmljs/src'
clang: error: no such file or directory: 'HD'
clang: error: no such file or directory: '2/Projects/bla/code/bla.js/node_modules/libxslt/node_modules/libxmljs/vendor/libxml/include'
make: *** [Release/obj.target/libexslt/deps/libxslt/libexslt/common.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)

This is an Open Issue:

> fsevents@0.2.0 install /usr/local/lib/node_modules/karma/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild

make: *** No rule to make target `../../../../../../../../../../Volumes/Macintosh', needed by `Makefile'.  Stop.
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Darwin 13.2.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/karma/node_modules/chokidar/node_modules/fsevents
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 

workaround not working for me too