lukechilds / zsh-nvm

Zsh plugin for installing, updating and loading nvm
MIT License
2.24k stars 113 forks source link

lazy-loading creates "attempt to assign private in nested scope" error #87

Open andronocean opened 2 years ago

andronocean commented 2 years ago

Hi, and thanks for this great project. I'm having an issue when loading zsh-nvm using zsh-snap ("znap") plugin manager with the setup shown at marlonrichert/zsh-launchpad.

I get this error: cmd: attempt to assign private in nested scope, related to this line in the _zsh_nvm_lazy_load function:

https://github.com/lukechilds/zsh-nvm/blob/23067bd9bb6eb6f4737a3ea90cb0cb5e85f61ba2/zsh-nvm.plugin.zsh#L106

I think this is happening since my .zshrc is configured to znap source plugins inside an anonymous function.

I was able to fix it by explicitly marking cmd as local:

# Create function for each command
  local cmd
  for cmd in $cmds; do