Allow global installation of NVM with individual user .nvm directories for Node installs#3056
Allow global installation of NVM with individual user .nvm directories for Node installs#3056chall8908 wants to merge 3 commits intonvm-sh:masterfrom
Conversation
…em-wide installs with a localized Nodes. Let's say we have nvm installed in a separate mount, /.socket. NVM_DIR is $HOME/.nvm in /etc/profile.d/nvm.sh. With this setup, users can install Node versions to their home directories without each installing nvm. nvm install --lts This works fine as does nvm use --lts. When nvm exec is used though, it fails because it looks for nvm-exec in $NVM_DIR. First fix is to look for nvm-exec in $NVM_DIR. If NVM_DIR does not contain nvm-exec, check $BASH_SOURCE[0]. The second fix is to follow nvm-exec if a symbolic link to determine the proper location of nvm's home. Alternatively we could use a second environment variable, NVM_HOME in exec instead of relying on the directory name of nvm-exec.
|
@chall8908 please don't open duplicate PRs - instead post a link to the branch on the original one and I can update it. Now I have to keep both PRs in sync :-/ |
|
@ljharb I wasn't aware that was an option. I'll happily close this PR so you can update the other. |
|
Please don't; once opened a PR ref can never be deleted, so i'd rather keep them in sync. Feel free to keep updating this one to get tests passing. |
1958bc6 to
c74c74e
Compare
|
The failing Travis tests appear to be Python errors from the Node source itself. The errors all appear to be things expecting Python 2 and getting Python 3. I noticed that the past few test runs have all failed on these tests with the same errors from the few I spot checked. I'm wondering now if this isn't something that changed inside Travis somehow. Thoughts? |
|
oof, if so i'll have to take that up with travis. thanks, i'll investigate. |
c6cfc3a to
c20db2a
Compare
| #!/usr/bin/env bash | ||
|
|
||
| DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" |
There was a problem hiding this comment.
could this be considered a breaking change if someone's relying on the lack of realpath here, wrt symlinks?
|
|
||
| NVM_EXEC="${NVM_DIR}/nvm-exec" | ||
| if [ ! -f "${NVM_EXEC}" ]; then | ||
| NVM_EXEC="$(dirname "${BASH_SOURCE[0]-}")/nvm-exec" |
This PR is a clone of #1845; updated and rebased onto the current master and into a repo not tied to an unrelated project.
The goal is to provide a central install of NVM that permits users to have their own
$NVM_DIRwhere Node installs live but have NVM's core files live elsewhere. It is still required that a user's$NVM_DIRbe a directory where the current user has full access.I'm actively using a setup like this throughout the infrastructure I manage and am testing this specific change on a CI server I control. NVM, while not intending to be multi-user, actually works quite well outside of
nvm exec, which this PR resolves.I've made a few modifications from the original PR. Namely:
DIRdetermination innvm-exectarflag changes since specific flag applied appears to be the default for alltars I'm aware of and doesn't exist on OpenBSD'star, as far as I could tell.With the changes to the main
nvmscript, I've noticed that it's not even required to havenvm-execsymlinked into$NVM_DIRwhen executed asnvm exec. This change could also allow fornvm-execexec to be symlinked into a standard location for binaries (e.g. /usr/local/bin) to provide nvm-exec easily to system processes, though I haven't tested this personally.