bash /bin/sh^M: 错误的解释器:没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23097528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
/bin/sh^M: bad interpreter: No such file or directory
提问by that other guy
When I enter brew doctor
(or any brew
command) in my terminal, I get this as a response:
当我在终端中输入brew doctor
(或任何brew
命令)时,我得到以下响应:
-bash: /usr/local/bin/brew: /bin/sh^M: bad interpreter: No such file or directory
-bash: /usr/local/bin/brew: /bin/sh^M: 错误的解释器: 没有那个文件或目录
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?
我之前看到过^M
响应,我认为它与 dos 行结束文件有关。有没有办法来解决这个问题?
回答by Javier Roca
This worked for me:
这对我有用:
- Open file /usr/local/bin/brew with vi (
vi /usr/local/bin/brew
) - While on vi issue this commad (via esc or :)
:set fileformat=unix
- Close file on vi via
:wq!
- 用 vi (
vi /usr/local/bin/brew
)打开文件 /usr/local/bin/brew - 在 vi 上发出此命令时(通过 esc 或 :)
:set fileformat=unix
- 通过 vi 关闭文件
:wq!
The brew command should be OK now.
brew 命令现在应该可以了。
Regards.
问候。
回答by that other guy
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'
.
我不知道回车如何在酿造文件结束了,但是你也可以使用删除dos2unix
或通过管道它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.
更换旧的。