nvm icon indicating copy to clipboard operation
nvm copied to clipboard

Set NVM_DIR to real path to avoid symlink issues in #617

Open singlow opened this issue 9 years ago • 6 comments

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

singlow avatar Oct 14 '15 06:10 singlow

This would need tests to ensure it works across shell versions.

ljharb avatar Dec 22 '15 07:12 ljharb

@singlow , Any chance you'd be willing to write a test for this? Sure would help reduce clutter in our environment. :-P

btelles avatar Mar 02 '16 16:03 btelles

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).

ljharb avatar Mar 02 '16 16:03 ljharb

I will work on that ASAP

singlow avatar Mar 03 '16 16:03 singlow

@singlow do you have any interest in completing this PR?

ljharb avatar Jun 26 '16 23:06 ljharb

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?

ljharb avatar Mar 22 '23 22:03 ljharb