Last week, I randomly started getting the following message when I open a new terminal window:
~/.nvm/nvm.sh:114: parse error near `done'
I tried uninstalling and reinstalling nvm with the following commands:
$ rm -rf ~/.nvm
# remove the nvm load script from my zshell config
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
but I'm still getting the message. Here are the relevant lines (110-114) from nvm.sh:
local pathdir
pathdir=$(dirname "$node_path")
while [ "$pathdir" != "" ] && [ "$pathdir" != "." ] && [ "$pathdir" != "/" ] && [ "$pathdir" != "$tree" ]; do
pathdir=$(dirname "$pathdir")
done
@stevehanson what's nvm debug print out? Does the same thing happen in bash, or is it only in zsh?
@ljharb: The nvm command doesn't work. I get zsh: command not found: nvm.
oh, duh, that makes sense. what's echo $HOME; print out? does npm config get prefix print anything?
$ echo $HOME
> /Users/shanson
$ npm config get prefix
> /usr/local
And thanks for your help, @ljharb!
np, we'll figure this out one way or another :-)
Do you use oh-my-zsh, or set any zsh options prior to sourcing nvm? (also can you check in bash too)
Yes, I use oh-my-zsh and have this custom path setup:
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/lib/node:$PATH
PATH=./bin:./vendor/bundle/bin:$PATH
PATH=$PATH:/opt/local/bin
PATH=$PATH:~/.dotfiles/scripts:~/.dotfiles/scripts/private
PATH=$PATH:~/bin
PATH=$PATH:~/go/bin
PATH=$PATH:~/.rbenv/bin:~/.rbenv/shims
eval "$(rbenv init -)"
export PATH
and then these two lines at the bottom of my zshrc, as inserted by the nvm install script:
export NVM_DIR="/Users/shanson/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
Also, I'm on a Mac (10.11.2), btw, if it's relevant.
As long as that PATH mutation is all happening before nvm runs, and not after, the only thing I can think of is the ~ - perhaps you could try using $HOME instead of ~ but i don't really think that will do it.
Could you also try disabling omz and using stock zsh? It would help to confirm that a zsh option is causing it (it's happened many times before with omz)
I just disabled omz by commenting out the line that sources it in my zshrc, and i'm still getting the same "parse error near done" error after opening a new terminal session.
oh wait!
When I comment out my custom zshell config that I source from zshrc, I don't get the error anymore and nvm is working. Awesome. Looks like something from that file. Let me comment out little chunks at a time to see if i can find the troublesome line.
Awesome, thanks! whatever it turns out to be, if it's possible to make nvm work around it, I'll try to do so.
omg. i found it. I had set up an alias to connect to my digital ocean server:
alias do=ssh [email protected]
can't believe it didn't hit me that do is a reserved word. Everything's working now. Thanks for all your help! I think you've taught me the skills to troubleshoot this on my own next time. cheers.
lol, glad we figured it out! thanks for being responsive!
@stevehanson this was EXACTLY my issue.
Excellent. I had the same problems. Thx for posting.. :)
I have got same issues, but just move this code below to before zsh configure on .zshrc file and it's work fine to me:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Thanks all,
FWIW, I had the _exact_ same alias, and the same confusion about the do loop in zsh.
i had very similar issue. i was trying to reset a reserved command to something else. alias fi='gfli' was causing the problem for me. but @stevehanson 's answer above helped me to resolve it.
omg. i found it. I had set up an alias to connect to my digital ocean server:
alias do=ssh [email protected]can't believe it didn't hit me that
dois a reserved word. Everything's working now. Thanks for all your help! I think you've taught me the skills to troubleshoot this on my own next time. cheers.
Just had this issue today and it's the exact same alias screwing it up. LMFAO
omg. i found it. I had set up an alias to connect to my digital ocean server:
alias do=ssh [email protected]can't believe it didn't hit me that
dois a reserved word. Everything's working now. Thanks for all your help! I think you've taught me the skills to troubleshoot this on my own next time. cheers.
Holy hell I had done the same thing...
alias do='docker'
Haha thanks for saving me more pain than needed.
In 2020, I had a similar issue with
alias done='send notification to my machine'
Thank you for opening this issue 馃樄
Most helpful comment
omg. i found it. I had set up an alias to connect to my digital ocean server:
can't believe it didn't hit me that
dois a reserved word. Everything's working now. Thanks for all your help! I think you've taught me the skills to troubleshoot this on my own next time. cheers.