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

Allow global installation of NVM with individual user .nvm directories for Node installs #3056

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chall8908
Copy link

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_DIR where Node installs live but have NVM's core files live elsewhere. It is still required that a user's $NVM_DIR be 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:

  • Simpler DIR determination in nvm-exec
  • Applied a change recommended by @ljharb on the original PR
  • Removed the tar flag changes since specific flag applied appears to be the default for all tars I'm aware of and doesn't exist on OpenBSD's tar, as far as I could tell.

With the changes to the main nvm script, I've noticed that it's not even required to have nvm-exec symlinked into $NVM_DIR when executed as nvm exec. This change could also allow for nvm-exec exec 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.

…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.
@ljharb
Copy link
Member

ljharb commented Mar 10, 2023

@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 ljharb marked this pull request as draft March 10, 2023 18:50
@chall8908
Copy link
Author

@ljharb I wasn't aware that was an option. I'll happily close this PR so you can update the other.

@ljharb
Copy link
Member

ljharb commented Mar 10, 2023

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.

@chall8908
Copy link
Author

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?

@ljharb
Copy link
Member

ljharb commented Mar 10, 2023

oof, if so i'll have to take that up with travis. thanks, i'll investigate.

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

Successfully merging this pull request may close these issues.

3 participants