Closed ahmedelgabri closed 7 years ago
Hey, thanks for taking the time to make an issue.
I'm afraid that wouldn't work as it's not just Node.js and global modules that are lazy loaded but also nvm
itself. We use the nvm_find_nvmrc
function (provided by nvm) to find the the .nvmrc
file and ensure consistency with nvm
. We need nvm to be loaded for this to be available.
We could resolve this by implementing the .nvmrc
search in zsh-nvm
but I'm not keen on this for two reasons:
zsh-nvm
should wrap nvm
with additional functionality, I want to avoid duplicating existing functionality..nvmrc
. I've tried to optimise it as much as possible. Also loading nvm
/Node.js/globals would make it hang for a significant amount of time.I'd suggest if you want to avoid slow shell startup but also use the auto use options you'd be better off using NVM_NO_USE
instead of NVM_LAZY_LOAD
. That way you'll have nvm (but no Node.js) available without much lag. If you navigate to a dir with an .nvmrc
file that version of Node.js will be activated automatically. The only caveat will be if you don't navigate to an .nvmrc
dir you'll need to manually nvm use default
before Node.js is available.
I was just hoping there is a way around it. I'm actually quite happy with my setup now, and I'm fine living with these caveats. Thanks for doing this!
@lukechilds Been running some benchmarks, and I don't find there's a performance increase in shell startup time with having NVM_NO_USE
set.
time zsh -i -c exit
with NVM_NO_USE
: 0.42s user 0.59s system 101% cpu 0.999 total
time zsh -i -c exit
with NVM_LAZY_LOAD
: 0.20s user 0.22s system 92% cpu 0.460 total
For now, I think I might stick with this, but there's still caveats:
if ! [ -f .nvmrc ]; then export NVM_LAZY_LOAD=true; fi
export NVM_AUTO_USE=true
I understand that this was mentioned in the
README.md
that we can't combine both, but I wonder if there is anything that can be done to make this work? I'd like to have bothMaybe when both are combined you just need to check if there is a
.nvmrc
file or not to load & use otherwise still be in lazy mode?