moovweb / gvm

Go Version Manager
http://github.com/moovweb/gvm
MIT License
9.87k stars 520 forks source link

Overriden cd fails to switch to paths with spaces #457

Open paulourio opened 6 months ago

paulourio commented 6 months ago

When attempting to use the cd command in bash, which runs $HOME/.gvm/scripts/env/cd, to navigate to a directory with spaces in its name, the operation fails with the error message "bash: cd: too many arguments." The expected behavior is a successful navigation to directories with spaces in their names.

How to reproduce:

  1. With initialized GVM, create a directory with spaces in its name:

    mkdir -p '~/foo bar'
    cd '~/foo bar'
  2. The following error is encountered:

    bash: cd: too many arguments

Environment:

haha4github commented 6 months ago

Faced the similar issue

cmodk commented 6 months ago

Have the same issue

albertosouza commented 5 months ago

After install gvm my cd stopped to work, if run any cd something and nothing happens. To solve that for now I deleted $HOME/.gvm/scripts/env/cd script to use the default linux cd. That gvm cd script is really need?

M4n5ter commented 5 months ago

The same issue

benyaminl commented 2 months ago

After install gvm my cd stopped to work, if run any cd something and nothing happens. To solve that for now I deleted $HOME/.gvm/scripts/env/cd script to use the default linux cd. That gvm cd script is really need?

I tried to delete that but seems it broke the improt of the "cd" in gvm file, could you please also point out where the import of the cd is?

Thank you

EDIT: NVM, I delete the row in .gvm/scripts/gvm-default at last row and it solved by itself... (for now for my own bash)

joes commented 1 month ago

This was totally unexpected and borks PATH in wsl 2 on windows as well.

See https://github.com/microsoft/WSL/issues/10399

matthewblott commented 1 month ago

I have this issue. I disabled the last command in the scripts/gvm-default file:

. "$GVM_ROOT/scripts/env/cd" && cd .

When I inspected the code I noticed there's a cd override function. That seems a bit dangerous to me! I'm on macOS but I'm using bash. I haven't tried with zsh but I suspect it's the same.