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

problem about installing nvm on ubuntu 1310 #394

Closed
amdoing opened this issue Apr 9, 2014 · 23 comments
Closed

problem about installing nvm on ubuntu 1310 #394

amdoing opened this issue Apr 9, 2014 · 23 comments
Labels
installing node Issues with installing node/io.js versions. OS: ubuntu

Comments

@amdoing
Copy link

amdoing commented Apr 9, 2014

I tried to install nvm on ubuntu 1310. first I run command below:
curl https://raw.github.com/creationix/nvm/v0.4.0/install.sh | sh

and then i activated nvm:
source ~/.nvm/nvm.sh

intsalled nodejs:
nvm install 0.10

finally I could use node normal. but after i had restarted system, the nvm didn't work,when run command such as "nvm ls", i got error prompt:

user@ubuntu:~$ nvm ls
sbin
mkdir: cannot create directory ‘/usr/sbin/alias’: Permission denied

@ljharb
Copy link
Member

ljharb commented Apr 9, 2014

i'm not familiar with "sbin". What shell are you using?

@ljharb ljharb added the Ubuntu label Apr 9, 2014
@amdoing
Copy link
Author

amdoing commented Apr 10, 2014

It's bash which is default shell on ubuntu.and Thanks for reply.

@koenpunt
Copy link
Contributor

You did activate nvm after you restarted? Because source ~/.nvm/nvm.sh has to run in every instance of the shell you use, thus the recommendation to add it to your .profile or alike.

@vicnala
Copy link

vicnala commented Apr 24, 2014

Hi!,

I think I have the same problem. In Ubuntu 14.04 I run:

git clone https://github.com/creationix/nvm.git ~/.nvm

And then I add source $HOME/.nvm/nvm.sh to .bashrc, restart shell and run:

$ echo $NVM_DIR 
/usr/sbin

Then nvm install (and others) command fails due permission errors.

I think the NVM_DIR env variable is setting wrong.

If I add export NVM_DIR="$HOME/.nvm" just before the source ... line in .bashrc, the install (and all the other) commands works as expected.

I have to add a nvm use ... in .bashrc to enable at least one version when shell starts (because there is none by default).

Recap: I have to add 3 lines to my .bashrc in Ubuntu:

export NVM_DIR="$HOME/.nvm"
source $HOME/.nvm/nvm.sh
nvm use 0.11

@ljharb
Copy link
Member

ljharb commented Apr 24, 2014

@vicnala can you use the install script? ./install.sh in the cloned repo.

@vicnala
Copy link

vicnala commented Apr 24, 2014

Hi @ljharb, the ./install.sh works fine setting NVM_DIR.

I only have to move the line added from .profile to .bashrc (I think Ubuntu does not load it).

Thanks!

@inetufo
Copy link

inetufo commented May 15, 2014

+1 ubuntu 12.04 echo $NVM_DIR is /usr/sbin, don't know why.

@inetufo
Copy link

inetufo commented May 15, 2014

use ./install.sh still gets the $NVM_DIR to /usr/sbin.It's very weird

@koenpunt
Copy link
Contributor

what does the line in your .profile look like?

@pervezfunctor
Copy link

This problem still persists for me. $NVM_DIR is /usr/sbin. The line in my .profile
[ -s "/home/pervez/.nvm/nvm.sh" ] && . "/home/pervez/.nvm/nvm.sh"

@pau4o
Copy link

pau4o commented May 28, 2014

Similar problem in Debian after fresh install.
In my case error is:

nvm ls
        gdm3
mkdir: cannot create directory '/etc/gdm3/alias': Permission denied

And $NVM_DIR is incorrectly set to /etc/gdm3

@koenpunt
Copy link
Contributor

A temporary fix would be to add export NVM_DIR=/home/pervez/.nvm to your profile before the source line:

export NVM_DIR=/home/pervez/.nvm
[ -s "/home/pervez/.nvm/nvm.sh" ] && . "/home/pervez/.nvm/nvm.sh"

But it seems that directory discovery is not working correctly in all shells...

@igregson
Copy link

Was having this same problem on a fresh install of Elementary OS Luna. Adding the "temporary fix" @koenpunt suggests did the trick (though it required a reboot).

@ghost
Copy link

ghost commented Jun 17, 2014

I've implemented the solution vicnala suggested and have since rebooted. But I still have to run source ~/.profile every time I open a terminal window to get nvm working. Weird.

@hokkaido
Copy link

Just as an information, I think most of these problems probably come from the fact that people are using Ubuntu's standard Gnome Terminal.

Gnome Terminal does not run bash as a login shell by default, and as such .profile is ignored by bash.

So you either put the information into .bashrc or you tell Gnome Terminal to run bash as a login shell (See the first link below). If you tell Gnome Terminal to run bash as a login shell, .bashrc won't be read. Of course there are options to circumvent this behavior: the second and third link below provide some answers.

More info:

http://askubuntu.com/questions/279180/nvm-command-not-found-issue
http://askubuntu.com/questions/132276/configure-gnome-terminal-to-start-bash-as-a-login-shell-doesnt-read-bashrc
http://askubuntu.com/questions/121073/why-bash-profile-is-not-getting-sourced-when-opening-a-terminal

@creationix
Copy link
Collaborator

I usually use ubuntu with gnome-terminal when in linux, but then again, I always manually added the line to my .bashrc instead of using the installer script. I can see how this would be for a problem for people who don't know .profile doesn't get run.

@lesterzone
Copy link

What about:

curl https://raw.githubusercontent.com/creationix/nvm/v0.24.1/install.sh | bash
source ~/.nvm/nvm.sh
nvm install v0.12.2
nvm alias default v0.12.2
nvm use v0.12.2

@ljharb
Copy link
Member

ljharb commented Apr 16, 2015

That will work, except you'll need to source nvm.sh in the appropriate profile file, if you're not already.

@typefish
Copy link

Ok, so I finally figured out the problem - I wasn't running nvm use stable after installing node. To test I removed the PATH stuff from .profile and then ran nvm use stable and it automatically added the path. I don't know if it is suppose to or not but nvm could run this when you install node for the first time.

Thanks

@ljharb
Copy link
Member

ljharb commented Aug 24, 2015

@jasonabullard you may also wish to use nvm alias default stable which will auto-use for you.

@crtormen
Copy link

I'm having the same problem.
First my shell wasnt recognizing nvm command, so I added the line
<[[ -s /home/$USER/.nvm/nvm.sh ]] && . /home/$USER/.nvm/nvm.sh>
to my .bashrc, restarted console, and then it recognize nvm command.
But now, when I try <nvm install> or <nvm alias> commands, it output this:
mkdir: it's not possible create dir “/home/crtormen/.nvm/bin/node-v5.1.0-linux-x64”: Permission denied

obs: <echo $NVM_DIR> is correctly outputing "/home/crtormen/.nvm"

Anybody could help me?

@ljharb
Copy link
Member

ljharb commented Dec 16, 2015

@crtormen you should have full permissions and ownership on everything inside $HOME - perhaps ensure that these are correct?

@ljharb
Copy link
Member

ljharb commented Jun 25, 2016

Closing this for now - happy to reopen if more debug or repro info can be provided.

@ljharb ljharb closed this as completed Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installing node Issues with installing node/io.js versions. OS: ubuntu
Projects
None yet
Development

Successfully merging a pull request may close this issue.