Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure when builddir contains spaces. #65

Closed
jasondavies opened this issue May 16, 2012 · 49 comments · May be fixed by #1038 or nodejs/gyp-next#204
Closed

Build failure when builddir contains spaces. #65

jasondavies opened this issue May 16, 2012 · 49 comments · May be fixed by #1038 or nodejs/gyp-next#204

Comments

@jasondavies
Copy link

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.

@TooTallNate
Copy link
Contributor

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

@TooTallNate
Copy link
Contributor

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

@cshenoy
Copy link

cshenoy commented Oct 15, 2012

Any updates to this issue?

@trentm
Copy link

trentm commented Nov 15, 2012

Added a pull that fixes at least the node-dtrace-provider (and hence the node-bunyan) issues mentioned here: #164

@jmwohl
Copy link

jmwohl commented Nov 12, 2013

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.

@Glavin001
Copy link

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

@sebnapi
Copy link

sebnapi commented May 28, 2014

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

@kfancy
Copy link

kfancy commented Aug 1, 2014

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)

@carstenhag
Copy link

Bump I guess? This still is an issue afaik.

@Mike-Dunton
Copy link

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 

@freder
Copy link

freder commented Mar 30, 2015

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)

@Zae
Copy link

Zae commented Jun 9, 2015

Any progress on this?

@nemoDreamer
Copy link

👍 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?

@davidrhoderick
Copy link

Still an issue on Mac OS X 10.9.5.

@kfancy
Copy link

kfancy commented Jul 15, 2015

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
#65 (comment)
.

@julienfdev
Copy link

Same issue here, can't build on Big Sur when path contains spaces and I have no control on the folder name

@cclauss
Copy link
Contributor

cclauss commented Sep 9, 2021

@jasondavies macOS workaround above #65 (comment)

@julienfdev
Copy link

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. 🤷‍♂️

@cclauss
Copy link
Contributor

cclauss commented Sep 9, 2021

Use backslash… HOME="/Mobile\ Documents/"

@julienfdev
Copy link

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 😐

@jessejiang0214
Copy link

Cannot believe this bug has existed for 10 years!!!
This still exists in v9.0.0 on MacOS

@hungtcs
Copy link

hungtcs commented Jun 16, 2022

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

@davej
Copy link

davej commented Jun 27, 2022

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

@hungtcs
Copy link

hungtcs commented Jun 28, 2022

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.

@relativeflux
Copy link

Can this be looked at, please?

@cclauss
Copy link
Contributor

cclauss commented Oct 26, 2022

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

tombruijn pushed a commit to tombruijn/gyp-next that referenced this issue Aug 17, 2023
Fix an installation issue that occurs when a path in which node-gyp is
run contains spaces.

For a path like `my app`, it would error with this message:

```
clang: error: no such file or directory: 'app/node_modules/node-addon-api'
```

The "my" part before the space (and the rest of the path before it)
would be missing from the path in the error message.

Fixes nodejs/node-gyp#65
tombruijn pushed a commit to tombruijn/gyp-next that referenced this issue Oct 30, 2023
Fix an installation issue that occurs when a path in which node-gyp is
run contains spaces.

For a path like `my app`, it would error with this message:

```
clang: error: no such file or directory: 'app/node_modules/node-addon-api'
```

The "my" part before the space (and the rest of the path before it)
would be missing from the path in the error message.

Fixes nodejs/node-gyp#65
@steam0r
Copy link

steam0r commented Nov 7, 2024

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

on osx:

works:

mkdir normal
cd normal/
npm install abletonlink

added 4 packages in 8s

1 package is looking for funding
  run `npm fund` for details

fails:

mkdir "with space"
cd with\ space/
npm install abletonlink

npm ERR! code 1
npm ERR! path /Users/xxx/Projects/npmtest/with space/node_modules/abletonlink
npm ERR! command failed
npm ERR! command /bin/bash -c node-gyp rebuild
npm ERR! CXX(target) Release/obj.target/abletonlink/src/napi-abletonlink.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.6 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
npm ERR! gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/xxx/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/xxx/Projects/npmtest/with space/node_modules/abletonlink/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/xxx/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/xxx/Library/Caches/node-gyp/20.13.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/xxx/Library/Caches/node-gyp/20.13.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/xxx/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/xxx/Library/Caches/node-gyp/20.13.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/xxx/Projects/npmtest/with space/node_modules/abletonlink',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! clang++: error: no such file or directory: 'space/node_modules/node-addon-api'
npm ERR! clang++: error: no such file or directory: 'space/node_modules/abletonlink/libs/link/include'
npm ERR! clang++: error: no such file or directory: 'space/node_modules/abletonlink/libs/link/modules/asio-standalone/asio/include'
npm ERR! make: *** [Release/obj.target/abletonlink/src/napi-abletonlink.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/Users/xxx/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Darwin 24.1.0
npm ERR! gyp ERR! command "/Users/xxx/.nvm/versions/node/v20.13.1/bin/node" "/Users/xxx/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/xxx/Projects/npmtest/with space/node_modules/abletonlink
npm ERR! gyp ERR! node -v v20.13.1
npm ERR! gyp ERR! node-gyp -v v10.1.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /Users/xxx/.npm/_logs/2024-11-07T08_37_07_102Z-debug-0.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment