获得“不良口译员"使用brew时出错 [英] Getting a "bad interpreter" error when using brew

查看:72
本文介绍了获得“不良口译员"使用brew时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试运行任何brew命令时出现此错误.

I'm getting this error when I try to run any brew command.

Holger-Sindbaeks-MacBook-Air:~ holgersindbaek$ brew help
-bash: /usr/local/bin/brew: /usr/bin/ruby: bad interpreter: No such file or directory

我绝对不知道如何解决这个问题,并且已经寻找了很长时间没有答案.

I have absolutely no idea on how to fix this and been searching for a long time without answer.

推荐答案

所获得的信息意味着Homebrew无法在指定位置定位Ruby解释器.

What you are getting means that Homebrew has not been able to locate the Ruby interpretter at the specified location.

安装Apple Developer Kit(Xcode附带),该软件应该作为可选安装提供给您(或者您可以简单地从Apple下载).这将为您安装Ruby解释器.

Install Apple Developer Kit (comes with Xcode) which should be available to you as an optional install (or you can simply download it from Apple). This will install the Ruby interpreter for you.

如果您已经安装了Xcode,则意味着其中之一正在发生:

In case you already have Xcode installed, this means that one of these things is happening:

  1. 您的Ruby安装失败了
  2. 您有多个Ruby安装
  3. 您的安装配置不正确.

要确定是否是第一种情况,可以运行ruby并查看是否收到任何响应.

To identify if this is the first case, you can run ruby and see if you get any response.

如果不这样做,则说明安装已损坏,需要重新安装.如果这样做,则运行which ruby.这应该为您提供Ruby可执行文件的绝对路径.如果不是/usr/bin/ruby以外的任何东西,那么自制程序(以及其他程序)将无法找到它.

If you don't, your installation is broken and you need to reinstall it. If you do, you then run which ruby. This should give you the absolute path to your Ruby executable. If this is anything other than /usr/bin/ruby then homebrew (and a bunch of other programs) will not be able to find it.

如果您从未篡改过Ruby安装,可以检查/usr/bin/ruby是否已经存在:cat /usr/bin/ruby.如果得到No such file or directory,则可以轻松地创建指向Ruby安装的符号链接.假设which ruby/usr/local/bin/ruby的输出,您可以通过以下方式创建符号链接:sudo ln -s /usr/local/bin/ruby /usr/bin/ruby,一切都应该很好.

In case you have not ever tampered with your Ruby installation, you can check to see if /usr/bin/ruby already exists or not: cat /usr/bin/ruby. If you get No such file or directory, then you can easily create a symbolic link to your Ruby installation. Assuming the output of which ruby to by /usr/local/bin/ruby, you create the symbolic link this way: sudo ln -s /usr/local/bin/ruby /usr/bin/ruby and all should be well.

如果该位置有文件,则可以运行file /usr/bin/ruby以查看它是真实文件,符号链接还是损坏的文件.如果它是一个符号链接,则您的安装应该可以正常工作,并且由于该链接不起作用,它可能是符号链接已损坏或伪造的文件.

If there is a file at that location, you can run file /usr/bin/ruby to see if it's a real file, a symbolic link, or a corrupted file. If it is a symbolic link, your installation should be working, and since it's not, it probably is either a corrupted symlink or it's a bogus file.

您可以通过以下方法进行补救:先将其删除(sudo rm /usr/bin/ruby),然后创建一个指向正确位置(sudo ln -s /usr/local/bin/ruby /usr/bin/ruby)的新符号链接.

You can remedy that by first deleting it (sudo rm /usr/bin/ruby) and then creating a new symlink to the correct location (sudo ln -s /usr/local/bin/ruby /usr/bin/ruby).

如果上述方法均无效,则应在全新安装Xcode并删除系统上所有Ruby安装的痕迹后,请教自制软件团队.

If non of the above works, you should consult the homebrew team after a clean install of Xcode and removing any traces of a Ruby installation on your system.

编辑

或者,如其他答案所指出的,该问题可能是由于Homebrew设置中的红宝石版本不良所致.

Alternatively, as pointed out by the other answers, the issue might be because of a bad ruby version in your Homebrew settings.

一个快速修复程序可能正在更新您的自制软件:

A quick fix might be updating your Homebrew:

cd /usr/local
git pull -q origin refs/heads/master:refs/remotes/origin/master

如果这没有帮助,则可能要弄脏您的手并通过以下方式手动解决问题:

If this does not help, you might want to get your hands dirty and manually fix the problem by:

  1. /user/local/Library/brew.rb
  2. 编辑brew.rb
  3. 在第一行中将/1.8/更改为/Current/,这将导致hashbang以执行者的身份指向当前Ruby版本
  1. Editing brew.rb from /user/local/Library/brew.rb
  2. Changing /1.8/ to /Current/ in the first line, which will cause the hashbang to point to the current Ruby version as the executor

如果这也无济于事,您还可以修改MACOS检查并将其从 10.5 更改为 10 ,以避免臭名昭著的自制软件需要豹纹或较高"的错误.

If this does not help, either, you can also modify the MACOS check and change it from 10.5 to 10 to avoid the infamous "Homebrew requires Leopard or higher" error.

免责声明

非常感谢以下回答中的其他贡献者及其评论者.我不是在进行窃,只是将答案汇总到一篇综合文章中来帮助其他人.

A bunch of thanks to other contributors in the answers below and their commenters. I am not committing plagiarism, simply aggregating the answers into one integrated article to help others.

这篇关于获得“不良口译员"使用brew时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆