Skip to content

login loop in Ubuntu #334

Closed
bevacqua opened this Issue Dec 18, 2013 · 27 comments
@bevacqua

nvm is causing me a login loop in Ubuntu. I'm using a zsh shell.

nvm

If I rm -rf ~/.nvm the problem goes away, but when I install nvm again, the problem comes back.

@koenpunt

It looks like /usr/sbin/lightdm-session has problems with nvm.sh, not zsh.

@bevacqua

yeah, the issue indeed is with nvm, I'm not very proficient with shell scripting, otherwise I'd fix this and submit a pull request, any thoughts?

@ljharb
Collaborator
ljharb commented Dec 26, 2013

What's lightdm-session? Can you try your OS without using that, and see if the problem still occurs?

@dosten
dosten commented Dec 26, 2013

@bevacqua you can comment nvm call in ~/.profile and ~/.bash_profile instead of remove all nvm.

@bevacqua

@ljharb lightdm is the display manager in the default distro of Ubuntu

@dosten I know, but the rm -rf statement is faster, I can just install it back afterwards

@creationix
Owner

I'm well aware of lightdm and how it's the default dm for unity in ubuntu, but I'm not familiar with how people set zsh as their default user shell. What is involved in doing this? How would I go from a stock ubuntu install to reproducing this issue?

@bevacqua

See zsh.sh in my dotfiles. I just use chsh

chsh -s `which zsh`
@afucher
afucher commented Dec 29, 2013

This line in ~/.profile is causing Login Loop for me:
[ -s $HOME/.nvm/nvm.sh ] && . $HOME/.nvm/nvm.sh # This loads NVM

I comment this, and can login again...

I found this here:
http://askubuntu.com/questions/395942/node-js-nvm-causes-xubuntu-login-loop-with-profile-line?newreg=51bd58007f2145b6b9f3cefe5cedc962

@dosten
dosten commented Dec 29, 2013

@afucher what is the content of your .xsession-errors file?

@afucher
afucher commented Dec 29, 2013

the same from the issue:
/usr/sbin/lightdm-session: 24: /home/fucher/.nvm/nvm.sh: Bad substitution
/usr/sbin/lightdm-session: 504: /home/fucher/.nvm/nvm.sh: Syntax error: "(" unexpected (expecting ";;")

@dosten
dosten commented Dec 29, 2013

@afucher try changing the shebang in .nvm/nvm.sh to #!/bin/bash. works for me if i use another shell instead sh (ex: bash, zsh)

@ljharb
Collaborator
ljharb commented Dec 29, 2013

Since nvm.sh has the #!/bin/sh shebang, it should really work by itself. While it's great that it can work by switching it to bash, that means that we're using bash syntax in a non-bash script, and that's the real issue that needs fixing.

@dosten
dosten commented Dec 29, 2013

In my system sh is a symlink of dash. can be dash the problem?

@bevacqua
@abhishekbhardwaj

I'm getting the same error as well. Here's what I've in my .xsession-errors file.

.nvm/nvm.sh: 24: .nvm/nvm.sh: Bad substitution
.nvm/nvm.sh: 504: .nvm/nvm.sh: Syntax error: "(" unexpected (expecting ";;")

As soon as I enter my password on the login screen in Ubuntu, the screen goes black for a second and then it brings the login screen back. Tried this with the newest version of NVM on GitHub.

Had this in my .profile:

[ -s $HOME/.nvm/nvm.sh ] && . $HOME/.nvm/nvm.sh

Removing that line immediately made Unity work.

@gwokae
gwokae commented Dec 30, 2013

My workaround is move this line [ -s $HOME/.nvm/nvm.sh ] && . $HOME/.nvm/nvm.sh # This loads NVM from ~/.profile to ~/.bashrc

@abhishekbhardwaj

@gwokae Did it stop the login loop?

@afucher
afucher commented Dec 30, 2013

I think the problem is that sh cannot make dynamic substitution... If nvm force to put this in bash and not in /.profile, it will works fine.

@magp
magp commented Dec 30, 2013

@abhishekbhardwaj : gwokae solution solves the loop (at least on my system)

@gwokae Thanks for this, saved my day!

@gwokae
gwokae commented Dec 30, 2013

@abhishekbhardwaj Yes, it works for me.
@magp You're welcome

@afucher
afucher commented Dec 30, 2013

I'm new in Ubuntu (Linux)..so what is the difference between @gwokae solution, or put source ~/.nvm/nvm.sh to ~/.bashrc as the README say?

@gwokae
gwokae commented Dec 30, 2013

@afucher These two files are just start scripts when user login. ~/.profile will firstly execute when user login. After ~/.profile executed, shell's start script will executed ( in bash it will be ~/.bashrc ). This stackoverflow explains very well.

@gwokae gwokae added a commit to gwokae/nvm that referenced this issue Dec 30, 2013
@gwokae gwokae fix #334 login looping 9a64b6d
@abhishekbhardwaj

@gwokae Thank you very much. It works on my system too! 👍

@BradMcEvilly

For Mac OSX use
. ~/.nvm/nvm.sh
in ~/.profile
and be sure to remove
[ -s $HOME/.nvm/nvm.sh ] && . $HOME/.nvm/nvm.sh
at the bottom of nvm.sh

@ljharb
Collaborator
ljharb commented Dec 31, 2013

~/.profile isn't a thing on Mac OS X that I'm aware of.

@avoliva
avoliva commented Jan 2, 2014

I'm using BASH and getting the same exact error in my .xsession-errors. Once I stopped loading nvm it worked.

@BradMcEvilly

@ljharb ~/.profile doesn't exist on Mac OS X by default. You need to create it in your home directory.
For more info, see:
http://trickortip.com/312/andres-felipe-diaz-2/where-is-the-profile-file-in-mac-os-x-lion-mac-terminal-trick.html/
or
http://superuser.com/questions/1031/profile-in-mac-os-x

@ljharb ljharb added the OS: ubuntu label Jul 9, 2014
@ljharb ljharb added a commit that closed this issue Sep 4, 2014
@ljharb ljharb Make .bashrc be checked first on install.
From #511. Closes #320. Closes #268. Closes #334. Fixes #497. Relates to
a7108e9
@ljharb ljharb closed this in a7108e9 Sep 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.