nvm
nvm copied to clipboard
adjust for symbolic links
Currently the nvm.sh script does not handle directories that are symbolic links. This is a common problem on servers that use symbolic links to persistent drives. For example, an admin might want to install nvm into /opt/local/node, but the real location (without the symlinks) is /files2/opt-local/node/nvm. This results in:
export NVM_DIR=/opt/local/node/nvm && . "$NVM_DIR/nvm.sh"
nvm is not compatible with the npm config "prefix" option: currently set to "/files2/opt-local/node/nvm/versions/node/v8.11.3"
Run `npm config delete prefix` or `nvm use --delete-prefix v8.11.3 --silent` to unset it.
Assuming the admin knows this issue and uses the real directory, there is no problem:
export NVM_DIR=/files2/opt-local/node/nvm && . "$NVM_DIR/nvm.sh"
The small change I am providing will get the real directory to avoid the problem with symbolic links.
I don't know if cd -P is available on all Linux systems, but I have tested in MacOS, RedHat, AWS AMI and Debian.
Does this perhaps fix #617 and then also close #1385, and then perhaps address some of the issues in #855?
The code looks good, but this is breaking existing unit tests for nvm_tree_contains_path.
@aiqui any interest in completing this PR?
I've started some more work on this in https://github.com/olivermg/nvm .
However, the current state does not yet fix the complaint of nvm whenever $HOME is being set to a path that contains a symlink. I'll see if I can find out some more and improve the situation.
Hey @olivermg, want to check on latest master branch, my PR from the other day adjusted the prefix check to handle symlinks, so it never hits the nvm_tree_contains_path code anymore.
(See also, #2146 and #2045)
@aiqui @olivermg i'd love to finish this PR and get it landed; would either of you be interested in doing that? @olivermg, you can comment a link to your branch and I'll pull in the changes.