git-bash $PATH cannot parse windows directory with space

前端 未结 7 1283
旧时难觅i
旧时难觅i 2020-12-10 10:37

I would like to use git-bash come with github client on a windows 7 (32bit) machine. Somehow, the git-bash has already learned the $PATH variables from windows

相关标签:
7条回答
  • 2020-12-10 10:58

    Why not using absolute path instead of relative path and if a folder of file name contains a space just use "" (quotes).

    Ex. cd C:/Users/"My Folder"

    0 讨论(0)
  • 2020-12-10 11:00

    git-bash runs in a Linux environment. As, linux doesn't recognize \ backslash in its directory path, you need to use / forwardslash. Use "" if you directory path contains spaces.

    0 讨论(0)
  • 2020-12-10 11:03

    Basically to confirm what is working: For environment variables use export keyword:

    export JAVA_HOME="/c/Program Files/Java/jdkxxxxx"
    

    same for PATH variable etc.

    You can put it in your ~/.bashrc . Then, use variables instead of direct string with spaces

    0 讨论(0)
  • 2020-12-10 11:07

    Use the bash declare command -

    $ declare -x PATH="/path with spaces":$PATH
    
    0 讨论(0)
  • 2020-12-10 11:14

    Put a backslash ("\") before the space.

    ex. cd My\ Documents

    0 讨论(0)
  • 2020-12-10 11:15

    The answer for me was close to that of Seagal82. I added the following line at the start of [PATH_TO_GITBASH_INSTALL]\etc\profile:

    export HOME="/c/Users/Username\ with\ spaces/"
    

    Then I started a new git bash window and all the paths in $PATH using $HOME got replaced with the anti-slashed space and work correctly.

    0 讨论(0)
提交回复
热议问题