Skip to content

Build failure when builddir contains spaces. #65

Closed
nodejs/gyp-next
#204

Description

@jasondavies

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.

Activity

  1. TooTallNate commented on May 16, 2012

    @TooTallNate
    Contributor

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

  2. TooTallNate commented on Jul 10, 2012

    @TooTallNate
    Contributor

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

  3. cshenoy commented on Oct 15, 2012

    @cshenoy

    Any updates to this issue?

  4. added a commit that references this issue on Nov 15, 2012
  5. trentm commented on Nov 15, 2012

    @trentm

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

  6. jmwohl commented on Nov 12, 2013

    @jmwohl

    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.

  7. Glavin001 commented on Jan 6, 2014

    @Glavin001

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

  8. added a commit that references this issue on Jan 6, 2014
    6bfb29b
  9. sebnapi commented on May 28, 2014

    @sebnapi

    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

  10. kfancy commented on Aug 1, 2014

    @kfancy

    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)

  11. carstenhag commented on Jan 23, 2015

    @carstenhag

    Bump I guess? This still is an issue afaik.

  12. Mike-Dunton commented on Feb 3, 2015

    @Mike-Dunton

    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 
    
  13. freder commented on Mar 30, 2015

    @freder

    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)
    
  14. Zae commented on Jun 9, 2015

    @Zae

    Any progress on this?

  15. nemoDreamer commented on Jun 29, 2015

    @nemoDreamer

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

  16. 30 remaining items

  17. cclauss commented on Sep 9, 2021

    @cclauss
    Contributor

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

  18. julienfdev commented on Sep 9, 2021

    @julienfdev

    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 😐

  19. jessejiang0214 commented on May 25, 2022

    @jessejiang0214

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

  20. hungtcs commented on Jun 16, 2022

    @hungtcs

    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

  21. davej commented on Jun 27, 2022

    @davej

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

  22. hungtcs commented on Jun 28, 2022

    @hungtcs

    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.

  23. relativeflux commented on Oct 25, 2022

    @relativeflux

    Can this be looked at, please?

  24. cclauss commented on Oct 26, 2022

    @cclauss
    Contributor

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

  25. steam0r commented on Nov 7, 2024

    @steam0r

    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 node-gyp@10.1.0
    npm ERR! gyp info using node@20.13.1 | 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
    
  26. added a commit that references this issue on Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions