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

nvm is confused by symlinks #1031

Closed
ebiggers opened this issue Mar 8, 2016 · 1 comment
Closed

nvm is confused by symlinks #1031

ebiggers opened this issue Mar 8, 2016 · 1 comment

Comments

@ebiggers
Copy link

ebiggers commented Mar 8, 2016

I cloned the nvm repository into a directory, then sourced nvm.sh via a symbolic link to that directory.

This causes nvm to error out due to incorrect "contains path" logic:

$ nvm use v5.1.0
nvm is not compatible with the npm config "prefix" option: currently set to "/opt/src/nvm/versions/node/v5.1.0"
Run `npm config delete prefix` or `nvm use --delete-prefix v5.1.0` to unset it.

Here's one possible fix:

diff --git a/nvm.sh b/nvm.sh
index b4e871f..7cd1e1d 100755
--- a/nvm.sh
+++ b/nvm.sh
@@ -98,9 +98,9 @@ fi

 nvm_tree_contains_path() {
   local tree
-  tree="$1"
+  tree="$(readlink -f "$1")"
   local node_path
-  node_path="$2"
+  node_path="$(readlink -f "$2")"

   if [ "@$tree@" = "@@" ] || [ "@$node_path@" = "@@" ]; then
     >&2 echo "both the tree and the node path are required"
@ljharb
Copy link
Member

ljharb commented Mar 9, 2016

This is a duplicate of #617 - for now, $NVM_DIR can not be a symlink.

I'm relatively sure readlink in that fashion is not POSIX - meaning, it won't work on all of bash, zsh, dash, sh, and ksh. PRs welcome if you can convince me that it is!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants