Question

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?

Was it helpful?

Solution 2

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

Example:

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.

OTHER TIPS

This worked for me:

  1. Open file /usr/local/bin/brew with vi (vi /usr/local/bin/brew)
  2. While on vi issue this commad (via esc or :) :set fileformat=unix
  3. Close file on vi via :wq!

The brew command should be OK now.

Regards.

For people using Intellij, open the gradlew file of your project. In the lower right corner of the IDE there will be one element written CRLF or LF or CR. Changed it to LF and it worked. (I'm using Windows+WSL)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top