Node-gyp: Build failure when builddir contains spaces.

Created on 16 May 2012  Â·  35Comments  Â·  Source: nodejs/node-gyp

See also: brianmcd/contextify#30.

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

> [email protected] 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 [email protected]

Notice the -I parameter is not escaped.

Multiple Reports User Friendly Windows

Most helpful comment

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

All 35 comments

Confirmed. It looks like it might be a gyp bug, but I'll have to experiment a little bit more.

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

Any updates to this issue?

Added a pull that fixes at least the node-dtrace-provider (and hence the node-bunyan) issues mentioned here: https://github.com/TooTallNate/node-gyp/pull/164

This still seems to be an issue... any progress on it? Setting the HOME env var didn't seem to help, though I may not be doing that correctly.

I still think this is an issue, @jmwohl.

Looking at the latest commit: https://github.com/TooTallNate/node-gyp/blob/7e98c99ce7e04e1599677a8b7919f7c387ad6a09/lib/configure.js#L311
And looking at the purposed solution: https://github.com/trentm/node-gyp/commit/bbd979bca2af5dfe29169ac50db17372fb4971b3

Looks like Pull Request was never merged: https://github.com/TooTallNate/node-gyp/pull/164

Proposed Solution (lines 311+), from @trentm:

Old

argv.push('-Dnode_root_dir=' + nodeDir)
argv.push('-Dmodule_root_dir=' + process.cwd())

Fixed

Add:

function shellEscape(str) {
   return str.replace(/(["\s'$`\\])/g, '\\$1');
};

Change to:

argv.push('-Dnode_root_dir=' + shellEscape(nodeDir))
argv.push('-Dmodule_root_dir=' + shellEscape(process.cwd()))

Maybe I am missing something? My only confirmation that it is still not working is from the issue I made on another repository: https://github.com/nodegit/nodegit/issues/123

Hope this can be resolved and merged soon!


Update:
Looks like the solution didn't completely work. Sorry for the false alarm :-1: .

This is an Open Issue:

> [email protected] 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

Work-around (definitely OS X, probably unix*) until this is fixed:

  1. create a new account, with no spaces in the folder name
  2. log in as that user
  3. install globally:

npm install -g PACKAGENAME

(this worked for me, to install zmq)

Bump I guess? This still is an issue afaik.

I am still having this issue here is a log output.

[email protected] install /Users/michael dunton/projects/optimlol/node_modules/css-sprite/node_modules/lwip
> node-gyp rebuild

  CXX(target) Release/obj.target/lwip_decoder/src/decoder/init.o
clang: error: no such file or directory: 'dunton/.node-gyp/0.10.36/src'
clang: error: no such file or directory: 'dunton/.node-gyp/0.10.36/deps/uv/include'
clang: error: no such file or directory: 'dunton/.node-gyp/0.10.36/deps/v8/include'
make: *** [Release/obj.target/lwip_decoder/src/decoder/init.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:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Darwin 14.1.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/michael dunton/projects/optimlol/node_modules/css-sprite/node_modules/lwip
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 

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)

Any progress on this?

:+1: 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?

Still an issue on Mac OS X 10.9.5.

It's probably going to remain an issue, my recommendation is to either
create a separate account to install global modules as necessary, or go
through the steps of removing the space from your user account directory
name, steps outlined in the link below.

https://support.apple.com/en-us/HT201548

On Wed, Jul 15, 2015 at 9:45 AM, David Rhoderick [email protected]
wrote:

Still an issue on Mac OS X 10.9.5.

—
Reply to this email directly or view it on GitHub
https://github.com/TooTallNate/node-gyp/issues/65#issuecomment-121675195
.

But why should it remain an issue, @kfancy? Plenty of CLI's support spaces in paths (and this is not just about the user root), this just seems like some missing escaping or quoting around a path parameter?

The global install works nicely, but it's a work-around.

I'm not saying that it shouldn't be fixed, but given the longevity of the
bug obviously it's not a priority...
so, either fix your spaces in your name path, or do global. :-)

On Wed, Jul 15, 2015 at 11:57 AM, Philip Blyth [email protected]
wrote:

But why should it remain an issue, @kfancy https://github.com/kfancy?
Plenty of CLI's support spaces in paths (and this is not just about the
user root), this just seems like some missing escaping or quoting around a
path parameter?

The global install works nicely, but it's a work-around.

—
Reply to this email directly or view it on GitHub
https://github.com/TooTallNate/node-gyp/issues/65#issuecomment-121712075
.

Good point... Hadn't noticed the :skull: date.

I ran into a similar problem under chrisa/node-dtrace-provider#65, and my failure mode looks a lot like the issue that https://codereview.chromium.org/287393002/ was intended to fix.

I have the same issue when I install webpack

As a hack, you can create a SYMLINK for the target dir with no spaces. I tried at /Volumes/DIR_NAME_WITH_SPACES to /Volumes/DIR_WITH_NO_SPACES, then exported all ENV variables - HOME* for the newly defined value. This worked for me as my hard drive name contained spaces, changing from "Macintosh\ HD" to MacintoshHD via a symlink allowed webpack (node-gyp, fsevents,...) to install properly. YMMV

This is still an issue!

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......

This is still an issue!

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

Still an issue, even if it has a workaround it should be great if node-gyp could manage spaces in paths or send a warning about that :)

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

Bumping

^ Rude.

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

it's not going to change; gyp itself doesn't support blanks in paths.

If someone would like to patch gyp to handle spaces in paths that would be fine, but raising issues in node-gyp isn't helpful.

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

/ Building module: bindings, Completed: 0Attempting to build a module with a space in the path
See https://github.com/nodejs/node-gyp/issues/65#issuecomment-368820565 for reasons why this may not work
× Rebuild Failed

An unhandled error occurred inside electron-rebuild
'F:\Psitron' is not recognized as an internal or external command,
operable program or batch file.
'D' is not recognized as an internal or external command,
operable program or batch file.

Failed with exit code: 1

Error: 'F:\Psitron' is not recognized as an internal or external command,
operable program or batch file.
'D' is not recognized as an internal or external command,
operable program or batch file.

Failed with exit code: 1
    at SafeSubscriber._error (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\node_modul
es\spawn-rx\lib\src\index.js:267:84)
    at SafeSubscriber.__tryOrUnsub (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\node
_modules\rxjs\internal\Subscriber.js:205:16)
    at SafeSubscriber.error (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\node_module
s\rxjs\internal\Subscriber.js:156:26)
    at Subscriber._error (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\node_modules\r
xjs\internal\Subscriber.js:92:26)
    at Subscriber.error (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\node_modules\rx
js\internal\Subscriber.js:72:18)
    at MapSubscriber.Subscriber._error (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\
node_modules\rxjs\internal\Subscriber.js:92:26)
    at MapSubscriber.Subscriber.error (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\n
ode_modules\rxjs\internal\Subscriber.js:72:18)
    at SafeSubscriber._next (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\node_module
s\spawn-rx\lib\src\index.js:242:65)
    at SafeSubscriber.__tryOrUnsub (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\node
_modules\rxjs\internal\Subscriber.js:205:16)
    at SafeSubscriber.next (F:\Psitron Technologies\CONF DOC\R&D LoRa\BOM\Software\COM\electron-quick-start\node_modules
\rxjs\internal\Subscriber.js:143:22)

_Hey guys,

I hope you all doing good, Thanks in advance. Really I tried 100 way to get rid of these errors. I couldn't.I need your advice._

F:\Psitron Technologies\CONF DOC\R&D LoRa —>
F:\Psitron_Technologies\CONF_DOC\R&D_LoRa ?

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

How can I fix this on a PC running Windows 10?

Was this page helpful?
0 / 5 - 0 ratings