问题描述
我正在尝试在OS X El Capitan上安装Homebrew.
I'm trying to install Homebrew on OS X El Capitan.
我使用以下命令来安装Homebrew:
I used the following command to install Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
到目前为止,它一直有效.但是,如果我尝试运行任何brew命令,例如:
So far it worked. But then if I tried to run any brew command, for example:
brew help
我得到了错误:
-bash: /usr/local/bin/brew: /bin/bash^M: bad interpreter: No such file or directory
因此,我尝试了此线程的两个最佳答案(将brew的文件格式设置为UNIX).现在,无论我运行任何Brew命令(例如Brew Doctor或Brew Help),我都会得到:
So I tried both top answers of this thread (which sets the file format of brew to unix). Now, whatever brew command I run (e.g. brew doctor or brew help), I get:
: command not foundbrew.sh: line 2:
'usr/local/Library/brew.sh: line 3: syntax error near unexpected token `{
'usr/local/Library/brew.sh: line 3: `odie() {
如何解决此语法错误,以便最终可以使用Homebrew?预先感谢您的任何建议!
How do I fix this syntax error so I'm finally able to use Homebrew? Thanks in advance for any advice!
澄清.
推荐答案
^M
通常表示\r
,就像\r\n
一样,它是Windows行尾.
^M
usually means \r
as in \r\n
which is windows line endings.
您应该尝试打开/usr/local/bin/brew
并将其保存为unix行尾,或者使用命令行dos2unix
为您完成这项工作:
You should try to open /usr/local/bin/brew
and save it with unix line endings or use the command line to dos2unix
to do the job for you:
dos2unix /usr/local/bin/brew
您可能还会遇到其他具有相同问题的文件,例如:usr/local/Library/brew.sh
You might encounter other files with the same problem, eg: usr/local/Library/brew.sh
这篇关于Mac OS X(El Capitan)上的自制软件:意外令牌`{附近的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!