/bin/sh^M: bad interpreter: No such file or directory

When I enter brew doctor(or any brew command) in my terminal, I get this as a response:

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

I have seen the ^M response before and I think it has to do with dos line ending files. Is there a way to fix this?


I don’t know how carriage returns ended up in your brew file, but you can remove them using dos2unixor by piping it through tr -d '\r'.


tr -d '\r'  < /usr/local/bin/brew   > myfixedbrew

Once verified, you can use

mv myfixedbrew /usr/local/bin/brew && chmod a+x /usr/local/bin/brew 

to replace the old one.



执行下 tr –d ‘\r’替换下编码即可。


About 智足者富



电子邮件地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>