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

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

singlow
Copy link

@singlow singlow commented Oct 14, 2015

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

@ljharb
Copy link
Member

ljharb commented Dec 22, 2015

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

@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label Dec 22, 2015
@btelles
Copy link

btelles commented Mar 2, 2016

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

@ljharb
Copy link
Member

ljharb commented Mar 2, 2016

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

@singlow
Copy link
Author

singlow commented Mar 3, 2016

I will work on that ASAP

@ljharb
Copy link
Member

ljharb commented Jun 26, 2016

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

@ljharb

This comment was marked as resolved.

@ljharb ljharb force-pushed the master branch 2 times, most recently from c6cfc3a to c20db2a Compare June 10, 2024 18:13
@ljharb ljharb marked this pull request as draft February 3, 2025 17:23
@ljharb ljharb force-pushed the fix_symlink_nvm_dir branch from 61cc654 to a0e9c15 Compare February 3, 2025 20:27
@ljharb
Copy link
Member

ljharb commented Feb 3, 2025

Looks like this is failing tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs followup We need some info or action from whoever filed this issue/PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants