XYZ
XYZ

Reputation: 27387

oh-my-zsh Command Not Found: ^M

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?

Upvotes: 15

Views: 13741

Answers (4)

Luciano Sclovsky
Luciano Sclovsky

Reputation: 388

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

Upvotes: 15

Hinrich
Hinrich

Reputation: 13983

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

Upvotes: 2

남기웅
남기웅

Reputation: 11

I had the same issue, and autocrlf=true did not resolve the issue. After I disabled the git plugin in ~/.zshrc by commenting it out, and removed & replaced the file which has the problem ^M, it was resolved. It seems git plugin on oh-my-zsh makes a conflict.

    #plugins=(git)

Upvotes: 1

XYZ
XYZ

Reputation: 27387

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.

Upvotes: 11

Related Questions