Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust for symbolic links #2143

Open
wants to merge 2 commits into
base: master
from
Open

adjust for symbolic links #2143

wants to merge 2 commits into from

Conversation

@aiqui
Copy link

aiqui commented Jan 8, 2020

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.

Co-Authored-By: Charlie Hileman <aiquicorp@gmail.com>
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
Copy link
Member

ljharb left a comment

Turns out cd -P is indeed in POSIX! https://pubs.opengroup.org/onlinepubs/9699919799/utilities/cd.html \( ゚◡゚)/

This will need tests.

nvm.sh Outdated Show resolved Hide resolved
@ljharb

This comment has been minimized.

Copy link
Member

ljharb commented Jan 8, 2020

Does this perhaps fix #617 and then also close #1385, and then perhaps address some of the issues in #855?

nvm.sh Show resolved Hide resolved
@ljharb

This comment has been minimized.

Copy link
Member

ljharb commented Jan 12, 2020

The code looks good, but this is breaking existing unit tests for nvm_tree_contains_path.

@ljharb ljharb force-pushed the aiqui:master branch from 9eb5d1c to e7e5b37 Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.