gvm icon indicating copy to clipboard operation
gvm copied to clipboard

Startup error when having `cd` already set as alias

Open ad-on-is opened this issue 1 year ago • 7 comments

I'm using zoxide which creates an alias for cd

This results in gvm throwing errors on startup of zsh.

/home/adonis/.gvm/scripts/env/cd:46: defining function based on alias `cd'
/home/adonis/.gvm/scripts/env/cd:46: parse error near `()'

ad-on-is avatar Feb 21 '24 19:02 ad-on-is

did you find a fix for this?

MushiTheMoshi avatar Aug 09 '24 21:08 MushiTheMoshi

I had this too, and just figured out how to solve it.

So the issue is that you already have an alias named cd. The solution is to either remove that alias, or just run unalias cd before that line. See https://stackoverflow.com/questions/76638009/zsh-script-is-throwing-a-syntax-error-parse-error-near.

viktornordling avatar Aug 26 '24 03:08 viktornordling

Well, now I can't actually use cd at all, as in, when I type cd .. or cd any-dir, I don't actually change directory. FML, I give up.

viktornordling avatar Aug 26 '24 03:08 viktornordling

I've temporarily solved the issue by redirecting all stderr to /dev/null. Just add the following line at the beginning of the script /Users/<user>/.gvm/scripts/env/cd.

exec 2>/dev/null

hrbasic avatar Dec 13 '24 14:12 hrbasic

I solved it by moving this line:

[[ -s "/Users/.../.gvm/scripts/gvm" ]] && source "/Users/.../.gvm/scripts/gvm"

above my alias setup (alias cd="z") in .zshrc

kamskr avatar Dec 20 '24 21:12 kamskr

I solved it by moving this line:

[[ -s "/Users/.../.gvm/scripts/gvm" ]] && source "/Users/.../.gvm/scripts/gvm"

above my alias setup (alias cd="z") in .zshrc

image

I can't use my cd now , I have try your solution, but I stiil can't use my cd. What should I do now?

bigbitbox avatar Jan 05 '25 12:01 bigbitbox

managed to work around it with

$ tail ~/.zshrc
...
unalias cd
[[ -s "/Users/YOU/.gvm/scripts/gvm" ]] && source "/Users/YOU/.gvm/scripts/gvm"
alias cd='exec_scmb_expand_args builtin cd'
...

ylhan avatar Mar 17 '25 16:03 ylhan