0

I'm trying to install Homebrew on OS X El Capitan.

I used the following command to install Homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

So far it worked. But then if I tried to run any brew command, for example:

brew help

I got the error:

-bash: /usr/local/bin/brew: /bin/bash^M: bad interpreter: No such file or directory

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() {

How do I fix this syntax error so I'm finally able to use Homebrew? Thanks in advance for any advice!

EDIT: Clarifying.

Community
  • 1
  • 1
ncw
  • 1,635
  • 1
  • 18
  • 26
  • 1
    You might want to report this to the Brew maintainers, either to find out what you did wrong (seemingly nothing), or to report this as a bug. – chepner Mar 26 '16 at 14:02

1 Answers1

1

^M usually means \r as in \r\n which is windows line endings.

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

You might encounter other files with the same problem, eg: usr/local/Library/brew.sh

Andreas Louv
  • 46,145
  • 13
  • 104
  • 123
  • Don't know why I didn't think of that. Change the fileformat of brew.sh also to unix fixed it. Thanks! – ncw Mar 26 '16 at 10:04