【问题标题】:oh-my-zsh Command Not Found: ^Moh-my-zsh 命令未找到:^M
【发布时间】:2016-08-27 22:02:08
【问题描述】:

我正在尝试在 Ubuntu 15 上安装 oh-my-zsh。运行安装脚本后

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

我有以下从未发生过的错误

/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

如何删除^M

【问题讨论】:

    标签: zsh oh-my-zsh


    【解决方案1】:

    解决方法是将autocrlf=true设置为autocrlf=false,使用下面的命令,

    git config --global core.autocrlf true
    

    ^M 是回车符 (CR),Windows 样式的文本行结尾 make。

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,但 autocrlf=true 没有解决问题。 在我通过注释禁用 ~/.zshrc 中的 git 插件并删除并替换有问题 ^M 的文件后,它得到了解决。似乎 oh-my-zsh 上的 git 插件发生了冲突。

          #plugins=(git)
      

      【讨论】:

        【解决方案3】:

        在我的 Mac 中,为 Oh-My-Zsh 安装的所有文件运行了 dos2unix。总而言之,它类似于以下内容。我一直在重新运行 source ~/.zshrc 以检查安装是否正常,没有任何错误,直到我转换了所有文件,包括二进制文件。

        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
        

        【讨论】:

        • 这个答案也是 linux 用户的解决方案。 dos2unix 解决了问题
        【解决方案4】:

        我可以通过在 LF 模式下保存文件 ~/.zshrc 在 Ubuntu 中解决此错误。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-04-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-12-23
          相关资源
          最近更新 更多