Build failure when builddir contains spaces.
jasondavies opened this issue Β· 48 comments
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.
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: #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: trentm@bbd979b
Looks like Pull Request was never merged: #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: nodegit/nodegit#123
Hope this can be resolved and merged soon!
Update:
Looks like the solution didn't completely work. Sorry for the false alarm π .
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
Work-around (definitely OS X, probably unix*) until this is fixed:
- create a new account, with no spaces in the folder name
- log in as that user
- 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.
lwip@0.0.5 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?
π 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 notifications@github.com
wrote:
Still an issue on Mac OS X 10.9.5.
β
Reply to this email directly or view it on GitHub
#65 (comment)
.
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 notifications@github.com
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
#65 (comment)
.
Good point... Hadn't noticed the π 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:
- Create a link file without space
sudo ln -s /Users/abc\ 1 /Users/abc
- specify
HOME
env to install
HOME=/Users/abc npm install
How can I fix this on a PC running Windows 10?
Γ Rebuild Failed
An unhandled error occurred inside electron-rebuild
'C:\Users\Awaghade' is not recognized as an internal or external command,
operable program or batch file.
Failed with exit code: 1
Error: 'C:\Users\Awaghade' is not recognized as an internal or external command,
operable program or batch file.
Failed with exit code: 1
at SafeSubscriber._error (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\spawn-rx\lib\src\index.js:267:84)
at SafeSubscriber.__tryOrUnsub (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\rxjs\internal\Subscriber.js:205:16)
at SafeSubscriber.error (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\rxjs\internal\Subscriber.js:156:26)
at Subscriber._error (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\rxjs\internal\Subscriber.js:92:26)
at Subscriber.error (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\rxjs\internal\Subscriber.js:72:18)
at MapSubscriber.Subscriber._error (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\rxjs\internal\Subscriber.js:92:26)
at MapSubscriber.Subscriber.error (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\rxjs\internal\Subscriber.js:72:18)
at SafeSubscriber._next (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\spawn-rx\lib\src\index.js:242:65)
at SafeSubscriber.__tryOrUnsub (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\rxjs\internal\Subscriber.js:205:16)
at SafeSubscriber.next (C:\Users\Awaghade Family\Downloads\mBlock-master (1)\mBlock-master\node_modules\rxjs\internal\Subscriber.js:143:22)
npm ERR! code ELIFECYCLE
npm ERR! errno 4294967295
npm ERR! mBlock@4.0.0 rebuild-serialport: electron-rebuild -f -w serialport
npm ERR! Exit status 4294967295
npm ERR!
npm ERR! Failed at the mBlock@4.0.0 rebuild-serialport script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Awaghade Family\AppData\Roaming\npm-cache_logs\2021-02-19T05_43_17_172Z-debug.log
i have the same issue . can anyone please help me out. i am using windows 10.
i cannot use node-gyp on Windows 10 Pro because of spaces in folder names. I cannot change the folders names.
It happens for me when a python process is being spawned, but the passed arguments/parameters are not escaped.
Same issue here, can't build on Big Sur when path contains spaces and I have no control on the folder name
@jasondavies macOS workaround above #65 (comment)
Thanks, that's not exactly the problem, I should have explained it better :
I never include spaces in my folder names, the problem comes from the /Mobile Documents/ (iCloud), it's located at
${HOME}/Library/ so setting the HOME variable won't do the trick. π€·ββοΈ
Use backslash⦠HOME="/Mobile\ Documents/"
Thanks Christian but that won't work.
The problem is not that node-gyp is trying to write temp files in a HOME path containing spaces that need escaping (what the HOME workaround actually fixes), the problem is when gyp is trying to access a file at a path containing spaces, doesn't matter if it's located in your home directory or not, it's not using the HOME variable at all when resolving this path.
Looks like there's nothing we can do about it as the problem comes from gyp itself, not node-gyp π
Cannot believe this bug has existed for 10 years!!!
This still exists in v9.0.0 on MacOS
Cannot believe this bug has existed for 10 years!!! This still exists in v9.0.0 on MacOS
When I move my projects to a mobile hard disk, I have a problem from 10 years ago
By the way, I created a PR for this last year but it hasn't seen any movement: #2556
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.
Can this be looked at, please?
Can we have a GitHub Action that fails which demonstrates this problem? Which pull request should be reviewed?