nvm
nvm copied to clipboard
Set NVM_DIR to real path to avoid symlink issues in #617
Proposed solution for #617
This pull request modifies NVM_DIR early in nvm.sh to point to the actual target of the symlink if the path is a symlink.
This way we don't have to worry about nvm actually working on a symlinked path. Is there a downside to this?
I commented a solution I am using on #855, but it used readlink which is non-Posix. The following is the alternative using pwd -P
in the same way that this pull request does.
export NVM_DIR=$(cd ~/.nvm && pwd -P)
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
This would need tests to ensure it works across shell versions.
@singlow , Any chance you'd be willing to write a test for this? Sure would help reduce clutter in our environment. :-P
I'll also want benchmarks to show how much this slows down shell startup time, in zsh
and bash
specifically (since zsh
has the hardest time being fast with nvm
).
I will work on that ASAP
@singlow do you have any interest in completing this PR?
ping @singlow; even if you're not interested in completing the PR, could you check the "allow edits" box on the RHS of the PR?