Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

On Debian, the end of the script doesn't succeed to source .zshrc #1315

Closed
kud opened this Issue Sep 14, 2012 · 31 comments

Comments

Projects
None yet

kud commented Sep 14, 2012

This is what I've got:

Looking for an existing zsh config...
Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc
Copying your current PATH and adding it to the end of ~/.zshrc for you.
Time to change your default shell to zsh!
Password: chsh: PAM authentication failed
         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/


 ....is now installed.
sh: 39: source: not found

I need to do $ source .zshrc manually in order to work correctly.

rhlobo commented Sep 18, 2012

The exact same thing here...

 Cloning into '/home/rhlobo/.oh-my-zsh'...
 remote: Counting objects: 4314, done.
 remote: Compressing objects: 100% (1687/1687), done.
 remote: Total 4314 (delta 2553), reused 3949 (delta 2380)
 Receiving objects: 100% (4314/4314), 556.55 KiB | 98 KiB/s, done.
 Resolving deltas: 100% (2553/2553), done.
 Looking for an existing zsh config...
 Found ~/.zshrc. �[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh
 Using the Oh My Zsh template file and adding it to ~/.zshrc
 Copying your current PATH and adding it to the end of ~/.zshrc for you.
 Time to change your default shell to zsh!
 Password: Password: chsh: PAM authentication failed
      __                                     __   
   ____  / /_     ____ ___  __  __   ____  _____/ /_  
  / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ 
 / /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / 
 \____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  
                     /____/                       


  ....is now installed.
 sh: 39: source: not found

But what you said does not work...

$ source .zshrc
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: No such file or directorysh
: command not found

UPDATE:
Actually, .zshrc has a ^M (ENTER) character at the end of each line.

/home/rhlobo/.zshrc:3: command not found: ^M
/home/rhlobo/.zshrc:9: command not found: ^M
/home/rhlobo/.zshrc:13: command not found: ^M
/home/rhlobo/.zshrc:16: command not found: ^M
/home/rhlobo/.zshrc:19: command not found: ^M
/home/rhlobo/.zshrc:22: command not found: ^M
/home/rhlobo/.zshrc:25: command not found: ^M
/home/rhlobo/.zshrc:28: command not found: ^M
/home/rhlobo/.zshrc:32: command not found: ^M
/home/rhlobo/.zshrc:33: command not found: ^M
/home/rhlobo/.zshrc:source:34: no such file or directory: /home/rhlobo/.oh-my-zsh^M/oh-my-zsh.sh^M
/home/rhlobo/.zshrc:35: command not found: ^M

UPDATE:
Even fixing this does not solve the issue...
Did :%s/^M//g on vi (^M can be done with Ctrl+V RETURN) but when trying to execute once more, oh-my-zsh.sh fails with errors a lot of errors

gavD commented Sep 24, 2012

I'm getting this error too on Ubuntu 12.04

I am also facing the same issue on Ubuntu 12.04.

rhlobo commented Sep 27, 2012

I've been trying to solve this but it seems I am too much of a beginner to find problems in the time I have available... Will take a deeper look at it later.

For now, I've peeked the installation script and it seems the first problem I am experiencing is about the change login shell command. In the installation it tries to authenticate without success, so I've done it manually:

 $ chsh -s `which zsh`
 Password: 

After that, I solved a problem in .zshrc I have described in my last comment. Did $ vim ~/.zshrc:

 ESC
 `:%s/^M//g` (^M can be done with Ctrl+V RETURN) replaced all the RETURN characters.

Next step, I've $ /usr/bin/env zsh without success. Parse error at line 28, where a double pipe (|| which indicates that the next command should be executed if the preceding one fails) is in a new line just after a command followed by \. I could not see the problem there, but I've put everything in the same line.

Retrying I've got another error in line 33, indicating something wrong somewhere around an elif. Once more, it seems to me that the code is correct, causing me to decide to explore other approaches.

In the desperation moment, I though maybe something was using zsh specific syntax, so I've added #!/bin/zsh to the top of the file, but nothing was solved. Next idea did not work as well:

  • Deleted .oh-my-zsh and .zshrc
  • Uninstalled zsh
  • Reinstalled zsh
  • Configured zsh and got a terminal running it
  • Tryed installing it when already running a zsh shell

This time, chsh had its chance to ask for a password, but from that on nothing was different.

rhlobo commented Sep 27, 2012

kud, do you use Ubuntu 12.04 as well?

kud commented Sep 27, 2012

I used debian and I know use ubuntu the latest, yes. Same error everywhere.

rhlobo commented Nov 18, 2012

Ok. I've got some time and made it work. I am now using Ubuntu 12.10, but was having the same problem. The solution was to install it manually.

Before doing that, don't forget to install zsh:

 sudo apt-get install zsh

Manual installation:

 git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
 mv ~/.zshrc  ~/.zshrc.bkp
 cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
 chsh -s $(which zsh)

Clonning the repository solved the problems found when running the installation script.
Calling chsh manually solved the PAM authentication failure.

There are two problems with the script here. The first is line 28

chsh -s `which zsh`

PAM authentication fails because of the way the script is called (at least in the automatic install).

curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh

The install script is being piped into a sh process, which I believe is causing it to skip authenticating with PAM at all. That or something funky is happening with a sub-process due to the script being piped into sh and it just takes the script itself as input when it requests a password.

At line 38, after the nice "oh my zsh is now installed" ascii artwork gets printed to the console, the command /usr/bin/env zsh is run. This should change our shell to zsh at this point, but again I believe there's a problem with the way the script is being piped into sh, causing a process to be launched, which has its environment changed to zsh and terminates. Nothing happens to the environment of the script, nor to the user.

The final problem is the following line, number 39.

source ~/.zshrc

sh does not have a source command, instead it just uses the dot . command, i.e. . ~/.zshrc. However, this wouldn't work either anyway, regardless of the shell you're using. The zshrc file would be sourced for the install script, but not for the user's environment.

The fix is simple though, just ask the user to run the chsh command manually and source the file themselves. I think anyone who wants to use oh-my-zsh will be able to accomplish that much by themselves.

Owner

robbyrussell commented Dec 1, 2012

I don't have an Ubuntu machine available at the moment, but does someone have a proposed approach that'll work nicely across environments/distributions?

The only way I can see is to ask the user to do it themselves. It's not as nice as a fully automated install, but it's one of the limitations of a shell script. Any changes to the environment a script makes can't be passed back to the user.

Perhaps something along the lines of

echo "\033[0;32m"'         __                                     __   '"\033[0m"
echo "\033[0;32m"'  ____  / /_     ____ ___  __  __   ____  _____/ /_  '"\033[0m"
echo "\033[0;32m"' / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ '"\033[0m"
echo "\033[0;32m"'/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / '"\033[0m"
echo "\033[0;32m"'\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  '"\033[0m"
echo "\033[0;32m"'                        /____/                       '"\033[0m"

echo "\n\n \033[0;32m....is nearly installed.\033[0m"

echo "\033[0;34mPlease run the command 'chsh -s `which zsh` && /usr/bin/env zsh && . ~/.zshrc' to turn zsh into your default shell"

The only major issue I can see with that is any new terminals they open will revert back to whichever shell they used before, until they logout and then log back in again.

yuvadm commented Dec 3, 2012

@tomdiddle, so that doesn't really solve the issue ;)

Contributor

NeuralSandwich commented Dec 4, 2012

I believe the issue lies from the input being piped into sh. When chsh -s which zsh is executed the password filed is filled with either a new line character from the script or the following echo.

One work around I have found is using:
"wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh && sh install.sh"

This gets around the first problem, I haven't found anything for "source .zshrc" yet.

I had just thought of the same thing, glad to hear it works.

Sourcing the ~/.zshrc from within the script just isn't going to work, though. You could change the command to wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh && sh install.sh && . ~/.zshrc and you'd probably have a working oh-my-zsh for that shell. I don't know if further shells would before you restart the machine though.

Contributor

NeuralSandwich commented Dec 5, 2012

For me further shells seem to work. I have tested it out on my Debian server and it seems to stick. If you check my fork, to see.

Yep, works wonderfully in Ubuntu. New shells don't get zsh as the shell until I log out and back in, however--only the one in which you run the command.

Incidentally, it may be wise to check if zsh is installed. It wasn't on this VM for some reason, so the script just fell apart when it came to changing shell. Implemented a check here https://github.com/TomDiddle/oh-my-zsh/commit/f80b2727cb579fc5987ff11280ad65a9fa8646c3

Contributor

NeuralSandwich commented Dec 5, 2012

Just implemented TomDiddle@f80b272. So new shells don't open zsh? Hmm, I will need to test this out tonight. Thought I had it.

@NeuralSandwich It works great - Thanx!

I'm getting this issue using Ubuntu 12.04 (vagrant box) and this issue is 9 months old - was it never fixed?

same issues here, fresh install of debian 7.1.0
dist-upgrade 'd to sid
apt-get install zsh git

curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 135 100 135 0 0 450 0 --:--:-- --:--:-- --:--:-- 453
100 1541 100 1541 0 0 2951 0 --:--:-- --:--:-- --:--:-- 2951
Cloning Oh My Zsh...
Cloning into '/root/.oh-my-zsh'...
remote: Counting objects: 7251, done.
remote: Compressing objects: 100% (3861/3861), done.
remote: Total 7251 (delta 4168), reused 5776 (delta 2910)
Receiving objects: 100% (7251/7251), 1.00 MiB | 605.00 KiB/s, done.
Resolving deltas: 100% (4168/4168), done.
Checking connectivity... done
Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to ~/.zshrc
Copying your current PATH and adding it to the end of ~/.zshrc for you.
Time to change your default shell to zsh!
__ __
____ / /_ ____ ___ __ __ ____ _/ /
/ __ / __ \ / __ `
/ / / / /
/ / / __
/ /
/ / / / / / / / / / / // / / /(
) / / /
**// // // // //**, / /**/**// //
/____/

....is now installed.
sh: 38: source: not found

KingPin commented Jul 5, 2013

same issue on a clean ubuntu 13.10 saucy server install.

kud commented Jul 5, 2013

Bye bye oh-my-zsh, welcome Prezto. https://github.com/sorin-ionescu/prezto (notifications now off for me)

Contributor

NeuralSandwich commented Jul 5, 2013

There was a fix and a pull request sent. I guess it never got merged?

You should replace source with just . and you'll be back in business.

Edit your .zshrc and modify the line
source $ZSH/oh-my-zsh.sh
to be
. $ZSH/oh-my-zsh.sh

Thanks @monolive.

I did what you said. It worked perfectly for me.

I also use Ubuntu 12.04.

Same issues on a Linux Mint 16 box (Ubuntu 13.10), will prob follow the manual method

mv ~/.oh-my-zsh^M ~/.oh-my-zsh

solved my issue :)

from this link I found a solution from @ryaninhust:

sudo vim /etc/pam.d/chsh

then, comment auth required pam_shells.so

sudo chsh $USER -s $(which zsh)

done, logout and login.

@ghost

ghost commented Apr 18, 2015

robbyrussell closed this Mar 22, 2014

Really, you're just going to close the issue even though this happens on every single Ubuntu-based machine when installing OMZ from scratch?

Thank @NeuralSandwich this solved the same issue on ArchLinux.

Collaborator

mcornella commented Jul 10, 2015

@ghost can you open a new issue with your details? Separate people posted different problems here, and it's difficult to know what the actual issue is.
The part about the sh: 39: source: not found error was solved by using . instead of source, though the script is still wrong because it should exec a new zsh instead of calling it and then sourcing it like it's done now.

All the problems related to ^M cames from git (in my case)
just try:
git config --global core.autocrlf false
And then install oh-my-zsh and be happy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment