Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

oh-my-zsh Command Not Found: ^M

Tags:

zsh

oh-my-zsh

I am trying to install oh-my-zsh on Ubuntu 15. After running the installation script

sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

I have the following error which never occur before

/home/li-xinyang/.zshrc:3: command not found: ^M
/home/li-xinyang/.zshrc:9: command not found: ^M
/home/li-xinyang/.zshrc:12: command not found: ^M
/home/li-xinyang/.zshrc:16: command not found: ^M
/home/li-xinyang/.zshrc:19: command not found: ^M
/home/li-xinyang/.zshrc:22: command not found: ^M
/home/li-xinyang/.zshrc:25: command not found: ^M
/home/li-xinyang/.zshrc:28: command not found: ^M
/home/li-xinyang/.zshrc:31: command not found: ^M
/home/li-xinyang/.zshrc:34: command not found: ^M
/home/li-xinyang/.zshrc:39: command not found: ^M
/home/li-xinyang/.zshrc:44: command not found: ^M
/home/li-xinyang/.zshrc:47: command not found: ^M
/home/li-xinyang/.zshrc:52: command not found: ^M
/home/li-xinyang/.zshrc:53: command not found: ^M
/home/li-xinyang/.zshrc:55: command not found: ^M
/home/li-xinyang/.zshrc:58: command not found: ^M
/home/li-xinyang/.zshrc:source:59: no such file or directory: /home/li-xinyang/.oh-my-zsh/oh-my-zsh.sh^M
/home/li-xinyang/.zshrc:60: command not found: ^M
/home/li-xinyang/.zshrc:63: command not found: ^M
/home/li-xinyang/.zshrc:70: command not found: ^M
/home/li-xinyang/.zshrc:73: command not found: ^M
/home/li-xinyang/.zshrc:76: command not found: ^M

How can I remove ^M?

like image 867
X.Creates Avatar asked May 03 '16 01:05

X.Creates


3 Answers

In my Mac ran dos2unix for all files installed by Oh-My-Zsh. In summary it was something like below. I kept rerunning source ~/.zshrc to check if the installation was OK, without any errors, until I have converted all files, including binary files.

brew install dos2unix
cd /Users/<your user>/.oh-my-zsh
find . -name " *.sh" | xargs dos2unix -f
find . -name " *.zsh" | xargs dos2unix -f
dos2unix -f themes/robbyrussel.zsh-theme
cd 
dos2unix -f .zshrc
source ~/.zshrc
like image 72
Luciano Sclovsky Avatar answered Sep 21 '22 06:09

Luciano Sclovsky


The solution is to set autocrlf=true to autocrlf=false use the command below,

git config --global core.autocrlf true

^M is carriage return (CR), Windows-style text line ending make.

like image 28
X.Creates Avatar answered Sep 18 '22 06:09

X.Creates


I could resolve this error in Ubuntu by saving the file ~/.zshrc in LF mode.

like image 30
Hinrich Avatar answered Sep 20 '22 06:09

Hinrich