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

System-wide NVM doesn't seem to work properly #570

Closed
foxx opened this issue Nov 2, 2014 · 8 comments
Closed

System-wide NVM doesn't seem to work properly #570

foxx opened this issue Nov 2, 2014 · 8 comments
Labels
OS: ubuntu root / multiuser issues Anything related to using `sudo` or `su`, or using nvm across multiple user accounts.

Comments

@foxx
Copy link

foxx commented Nov 2, 2014

As per #389 and #371, system-wide installs should be supported.

However I've done the following steps and it doesn't seem to work properly. Am I missing something here?

$ lsb_release -a
Description:    Ubuntu 14.04.1 LTS
Release:    14.04
Codename:   trusty

Install works fine

root# curl https://raw.githubusercontent.com/creationix/nvm/v0.17.3/install.sh | \
  NVM_DIR=/usr/local/nvm bash
=> Downloading nvm as script to '/usr/local/nvm'
=> Source string already in /root/.bashrc
=> Close and reopen your terminal to start using nvm

Using as root works fine

root# source /usr/local/nvm/nvm.sh
root# nvm install 0.10.32
Now using node v0.10.32
root# nvm ls
->  v0.10.32

Using as user fails

user# nvm ls
         N/A
mkdir: cannot create directory ‘/usr/local/nvm/alias’: Permission denied

user# nvm use 0.10.32
N/A version is not installed yet

Install as user fails

user# nvm install 0.10.32
mkdir: cannot create directory ‘/usr/local/nvm/bin’: Permission denied
Binary download failed, trying source.
mkdir: cannot create directory ‘/usr/local/nvm/src’: Permission denied
nvm: install v0.10.32 failed!
@koenpunt
Copy link
Contributor

koenpunt commented Nov 2, 2014

Create a group deploy (my suggestion) and set the group of /usr/local/nvm to it.
Make the /usr/local/nvm group writeable and add user to group.

Example (run as root):

groupadd deploy
chgrp deploy -R /usr/local/nvm
chmod -R g+w /usr/local/nvm
usermod -aG deploy USERNAME

@koenpunt
Copy link
Contributor

koenpunt commented Nov 2, 2014

Optionally, set the umask of /usr/local/nvm to 2775 so that files created in that directory are group writable by default:

chmod 2775 /usr/local/nvm # Yes, without -R

@ljharb
Copy link
Member

ljharb commented Nov 2, 2014

If you're doing a system-wide install, you've elected to manage permissions yourself (which is why your examples are failing) - @koenpunt's advice is solid.

It's very not recommended to share nvm across multiple users.

Also, for ubuntu-specific issues (thanks ubuntu!) see #394 for some extra tips.

@ljharb ljharb added OS: ubuntu root / multiuser issues Anything related to using `sudo` or `su`, or using nvm across multiple user accounts. labels Nov 2, 2014
@foxx
Copy link
Author

foxx commented Nov 2, 2014

Understood, I had assumed nvm worked by installing the binary in a system wide location, whilst still using ~/.nvm for local user usage. I'll opt for single user install instead as it's much easier, thanks both.

FWIW, would a docs patch be justified to explain this a bit better? Even if it's just a link to this issue for now?

@ljharb
Copy link
Member

ljharb commented Nov 2, 2014

Sure, I'm always happy to review PRs, especially for documentation, which is hard to objectively make intuitive for many varieties of people - so all feedback is welcome.

@ljharb
Copy link
Member

ljharb commented Dec 17, 2014

@foxx Any interest in that docs patch? If not, I'll close this issue for now.

@foxx
Copy link
Author

foxx commented Dec 17, 2014

@ljharb Sadly haven't got time to do this at the moment, feel free to close and I'll re-open when I get a chance, sorry!

@foxx foxx closed this as completed Dec 17, 2014
@allonhadaya
Copy link

@koenpunt thanks for the suggestion of using a group to share nvm!

You can source nvm.sh automatically for all group members using this system-wide profile script:

if groups $USER | grep -q '\bdeploy\b' -; then
  . /usr/local/nvm/nvm.sh
fi

Make sure to substitute deploy for whichever group you chose to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: ubuntu root / multiuser issues Anything related to using `sudo` or `su`, or using nvm across multiple user accounts.
Projects
None yet
Development

No branches or pull requests

4 participants