Closed robinloeffel closed 2 years ago
Figured it out! I've had two aliases defined before evaluating fnm env --use-on-cd
. If i move eval "$(fnm env --use-on-cd)"
to the top of my .zshrc
, all is peachy!
not really sure why this should fix it or what the diff was, but happy that it works. please feel free to share with more details. maybe it is a bug in the generated env :)
I have no idea why this fixed it, but the following .zshrc
works:
# prompt
export PROMPT="%F{cyan}%T%f > %F{green}%~%f 🔥 "
# brew
export PATH="/usr/local/sbin:$PATH"
# fnm
eval "$(fnm env --use-on-cd)"
# aliases
## brew
alias bup="brew update && brew upgrade && brew cleanup"
alias bi="brew install"
alias bu="brew uninstall"
alias br="brew reinstall"
alias bci="brew install --cask"
alias bcu="brew uninstall --cask"
alias bcr="brew reinstall --cask"
## yarn
alias ys="yarn start"
alias ya="yarn add"
alias yr="yarn remove"
alias yu="yarn upgrade-interactive --latest && yarn upgrade"
## fnm
alias fu="fnm use"
alias fi="fnm install"
## git
alias gitit="git clone"
## misc
alias ngr="sudo rm -rf $(xcode-select -print-path) && sudo rm -rf /Library/Developer/CommandLineTools && sudo xcode-select --reset && xcode-select --install"
Apart from that, I've changed absolutely nothing.
Hi @robinloeffel, FTR the problem is your use of fi
as an alias.
Shell scripts often make use of the if...fi
control statement, so fi
should be considered a keyword to avoid as an alias.
Even if your updated .zshrc noted above isn't triggering obvious errors, I still recommend using a different alias.
HTH! :)
That is unexpected. I wonder if we need to prepend a forward slash to avoid clashing. Great catch!
Hey @Schniz, I might be missing something, but... I don't think the issue had anything to do with fnm per se.
Creating an alias named fi
is problematic by definition, and that alias was something robinloeffel added by hand. Removing/renaming the alias eliminates the reported problem with eval "$(fnm env --use-on-cd)"
.
So, IMHO, it's a NOOP for fnm's maintainer! :)
Whenever I use
eval "$(fnm env --use-on-cd)"
in my.zshrc
, I get the following error in my terminal:(eval):16: parse error near add-zsh-hook'
, andfnm
isn't usable.If I use the old
eval "$(fnm env)"
, however, I can usefnm
with no problem.fnm env
prints the following, in both cases:I've installed it via
brew install fnm
, and tried re-installing it several times. My local machine is running:Edit: This is my whole
.zshrc
: