macos Homebrew - 错误的解释器:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9297387/
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
Homebrew - bad interpreter: No such file or directory
提问by Alex
Like an idiot, I managed to delete my system ruby install.
像个白痴一样,我设法删除了我的系统 ruby 安装。
I've re-installed xcode, and also installed RVM
我重新安装了 xcode,还安装了 RVM
Doing this:
这样做:
$ which ruby
returns this:
返回这个:
/Users/alex/.rvm/bin/ruby
However, Homebrew still seems to be broken:
然而,Homebrew 似乎还是被打破了:
$ brew
-bash: /usr/local/bin/brew: /usr/bin/ruby: bad interpreter: No such file or directory
回答by Bryan Rehbein
The system ruby on OS X is symlinked to the Ruby.framework. Since you reinstalled Xcode, it should be installed, but you need to restore the symlinks.
OS X 上的系统 ruby 符号链接到 Ruby.framework。由于您重新安装了 Xcode,它应该已安装,但您需要恢复符号链接。
First, check that this file exists and works.
首先,检查此文件是否存在并有效。
$ /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
If that command works, you should be able to setup the sym links again
如果该命令有效,您应该能够再次设置符号链接
cd /usr/bin
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/bin/ruby
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/erb /usr/bin/erb
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/gem /usr/bin/gem
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/irb /usr/bin/irb
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/rake /usr/bin/rake
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/rdoc /usr/bin/rdoc
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ri /usr/bin/ri
sudo ln -s ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/testrb /usr/bin/testrb
This should get you started, hopefully I haven't forgotten any of the binaries that need linked. There are other suggestions to reinstall ruby here: https://superuser.com/questions/171433/is-it-possible-to-reinstall-fix-mac-os-xs-system-ruby-without-doing-a-complete
这应该让你开始,希望我没有忘记任何需要链接的二进制文件。还有其他建议在这里重新安装 ruby:https: //superuser.com/questions/171433/is-it-possible-to-reinstall-fix-mac-os-xs-system-ruby-without-doing-a-complete
Another method in a gist: https://gist.github.com/1418384
要点中的另一种方法:https: //gist.github.com/1418384
回答by mipadi
brew
is hardcoded to use the system ruby. You could try change brew
's shebang (the first line) to /usr/bin/env ruby
, but it's not guaranteed to work with anything but the system Ruby (I'm not sure it's fully compatible with Ruby 1.9).
brew
硬编码以使用系统 ruby。您可以尝试将brew
的shebang(第一行)更改为/usr/bin/env ruby
,但不能保证除了系统 Ruby 之外的任何东西都可以使用(我不确定它是否与 Ruby 1.9 完全兼容)。
Or you could reinstall your system Ruby, which should be possibly by reinstalling OS X.
或者您可以重新安装系统 Ruby,这可能是通过重新安装 OS X 来实现的。
回答by 042e
If you don't want to have to reinstall the system ruby, the following should do the trick.
如果您不想重新安装系统 ruby,以下应该可以解决问题。
IMPORTANT:replace MY_USER_NAME
with the name of your home folder, which is the "short name" of your user in OS X.
重要提示:替换MY_USER_NAME
为您的主文件夹的名称,即您的用户在 OS X 中的“短名称”。
sudo ln -s /Users/MY_USER_NAME/.rvm/bin/ruby /usr/bin/ruby
回答by Jeremy Michael Cerda
There is a new link for Homebrew install
Homebrew 安装有一个新链接
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
回答by lentisas
Installation link for homebrew has been moved.
自制软件的安装链接已移动。
Here is the new one:
这是新的:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
回答by Gank
sudo rm -rf /usr/local/Cellar /usr/local/.git
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
I solved by reinstall brew.
我通过重新安装brew解决了。