I get the following error as soon as I source my ~/.zshrc
/home/taxborn/.nvm/nvm.sh:2038: parse error near `)'
I believe I have done everything right, and in the screen shot you can see that I have just installed it. Here is the line(s) in question.
if ! (
# shellcheck disable=SC2086
command mkdir -p "${TMPDIR}" && \
command "${tar}" -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")" && \
nvm_cd "${TMPDIR}" && \
nvm_echo '$>'./configure --prefix="${VERSION_PATH}" $ADDITIONAL_PARAMETERS'<' && \
./configure --prefix="${VERSION_PATH}" $ADDITIONAL_PARAMETERS && \
$make -j "${NVM_MAKE_JOBS}" ${MAKE_CXX-} && \
command rm -f "${VERSION_PATH}" 2>/dev/null && \
$make -j "${NVM_MAKE_JOBS}" ${MAKE_CXX-} install
); then # <--- This is line 2038
nvm_err "nvm: install ${VERSION} failed!"
command rm -rf "${TMPDIR-}"
return 1
fi

Thank you!
You'll note how the install script adds nvm lines to bashrc; but you're then using zshrc.
Does nvm work fine in bash? What's your zshrc look like?
It works fine in bash, and I have it added in my .zshrc.
Here are the lines of code added:
#NVM
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
I'm very confused :-/ the line in question hasn't changed in a long time, and if there was a syntax error, every zsh user would have been complaining for awhile now.
Can you share the rest of your zshrc, as well as the output of setopt?
setopt:
autocd
autopushd
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
incappendhistory
interactive
interactivecomments
longlistjobs
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
Yeah, this worked before, I used NVM for about a year and this only has happened in the past few weeks..
One thing that would be helpful is (assuming you're on v0.33.11 now) downgrading to v0.33.10, and seeing if the problem still occurs?
My stock zsh has:
combiningchars
interactive
monitor
nonomatch
shinstdin
zle
which means that the delta is:
alwaystoend
autocd
autopushd
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
incappendhistory
interactivecomments
longlistjobs
promptsubst
pushdignoredups
pushdminus
sharehistory
If you try a binary search on those options - disabling half, try again, re-enable and disable the other half, etc - that also would help determine the fix.
Hmm, same error, same line.. I can go into bash and install the node version I want, but still in ZSH it still seems to be the same error in v0.33.10 running the command:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.10/install.sh | bash
Thanks - if you're willing, we could also try going back farther - v0.33.0, v0.32.0 - trying to pin down which version it stopped working for you.
Alright, I tried v0.32.0 Still get the same parse error, but different line
/home/taxborn/.nvm/nvm.sh:1867: parse error near `)'
Is it worth mentioning I use Oh My Zsh too?
Also in v0.31.0, line 1428. This is pretty damn confusing
(yes, it was worth mentioning, but i inferred it from your zshrc - omz tends to break nvm all the time because it sets a bunch of nonstandard options)
Let's keep jumping back versions - v0.15.0 if needed :-) I'll need two things to fix it - the version where it broke (so i can find the commit that broke it) and then likely the zsh option that's causing it to be parsed differently.
I have some good news, v0.15.0 works without error! I'll go ahead and try to pinpoint the version. (somewhere between v0.31.0 and v0.15.0). Could you explain to me how I could find the ZSH option that could be impacting it?
Sweet, it works in v0.26.1 but not in v0.27.0. So somewhere in there something broke, at least for my setopt settings..
Thanks, that's the first step :-) https://github.com/creationix/nvm/compare/v0.26.1...v0.27.0 has a bunch of things.
For the options, you can use unsetopt alwaystoend etc, to unset the options (before sourcing nvm.sh) and see which one makes it fail.
Alright, after trying to binary-search my way through the setopt and unsetopt process, nothing came out of it. Still the same parse error :frowning:
Since nobody else has reported this, and the user has deleted their github account, I'm going to close this.
Happy to reopen if there's a way to repro.
Most helpful comment
Sweet, it works in
v0.26.1but not inv0.27.0. So somewhere in there something broke, at least for mysetoptsettings..