如何让 Ruby/Homebrew/RVM 在优胜美地工作?

在安装 Yosemite 之后,我无法运行 Brew 或 Ruby。

I was getting this error on brew update:

/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0

在 irb 上得到这个错误:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in mkdir': Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14 (Errno::EACCES) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:infu_mkdir'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:219:in block (2 levels) in mkdir_p' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:217:inreverse_each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:217:in block in mkdir_p' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:203:ineach'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:203:in mkdir_p' from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:210:inwrite_gem_make_out'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:132:in build_error' from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:171:inrescue in build_extension'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:156:in build_extension' from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:198:inblock in build_extensions'
from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:195:in each' from /Library/Ruby/Site/2.0.0/rubygems/ext/builder.rb:195:inbuild_extensions'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1436:in block in build_extensions' from /Library/Ruby/Site/2.0.0/rubygems/user_interaction.rb:45:inuse_ui'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1434:in build_extensions' from /Library/Ruby/Site/2.0.0/rubygems/stub_specification.rb:60:inbuild_extensions'
from /Library/Ruby/Site/2.0.0/rubygems/basic_specification.rb:56:in contains_requirable_file?' from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:925:inblock in find_inactive_by_path'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:924:in each' from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:924:infind'
from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:924:in find_inactive_by_path' from /Library/Ruby/Site/2.0.0/rubygems.rb:185:intry_activate'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/locale.rb:150:in block in search_file' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/locale.rb:158:inblock in each_localized_path'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/locale.rb:167:in each_sublocale' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/locale.rb:157:ineach_localized_path'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/locale.rb:145:in search_file' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/locale.rb:124:infind'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/locale.rb:108:in load' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/locale.rb:32:ininitialize'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/init.rb:114:in new' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/init.rb:114:ininit_config'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb/init.rb:16:in setup' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/irb.rb:380:instart'
from /usr/bin/irb:12:in `'
54807 次浏览

Steps to fix it:

  1. 为 Xcode 6安装命令行工具

  2. 重新安装咖啡机:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  3. Once brew is installed, rvm will work:

    rvm install ruby
    

Worked for me, yahoo!

这个错误可以通过以下步骤轻松修复:

1)终端机开放

2)类别 nano /usr/local/Library/brew.rb

3) In the first line change “1.8″ to “Current”, so it should look like this:

#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0

通过 http://blog.ic3man.gr/2014/06/homebrew-ruby-bad-interpreter-no-such-file-or-directory/

就像之前说的: 1)更改为电流 2)安装 xcode 6

如果你现在在酿酒和红宝石方面有进一步的问题,这个应该会有所帮助: 在版本1.8中,Brew 需要 Ruby,所以创建这个文件夹:

sudo mkdir -p /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin

然后做一个符号链接:

sudo ln -s /usr/bin/ruby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

这是从其他人的帖子中搜集的答案,以及在谷歌上的一点挖掘,但我想我会把它放在一个地方,这样一个完整的答案是在一个地方。具体来说,这使得现在的工作,但也让您像往常一样进行酿造更新,并得到一切清洁。

  1. Open/usr/local/Library/brew.rb (emacs/vi/nano/whatever)
  2. 将第一行更改为: #!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0。您只是将该行中的“1.8”更改为“ Current”(确保保留大写的“ C”,否则 git 以后会混淆)。
  3. cd $(brew --repository)
  4. git add Library/brew.rb
  5. git commit -m "upgrading to ruby 2.0"
  6. brew update(或者 sudo brew update,如果您的酿酒被设置为只使用 sudo 进行系统更改)

Credit: 尽管我真的建议不要在/usr/local 文件夹中执行 git commit -am,但其中很多都来自 给你

编辑脚本意味着 brew update无法工作; 对跟踪的文件进行本地编辑会导致 git pull失败。

我做了这个,我觉得这个更干净:

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

There are no complaints from brew doctor.

我更新到约塞米蒂,后来发现 abc 0坏了。

/usr/local/bin/brew: /usr/local/Library/brew.rb:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory /usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0

如果你还没有做出任何改变来酿造,这里是我的建议。否则请阅读下面的更多内容。

  1. cd /System/Library/Frameworks/Ruby.framework/Versions/
  2. sudo ln -s Current 1.8
  3. brew update
  4. sudo unlink 1.8

Already made changes to brew files and stuck in a git mess?

I tried to edit /usr/local/Library/brew.rb but the local change to my git repo was preventing brew update from pulling down updates. I tried some other solutions mentioned on this page and from other sites and I ended up with a git mess and all I wanted to do was undo everything I had done to brew.

我承诺我的改变,但它使事情变得更糟。最终,我不得不撤销我的提交和 git reset --hard HEAD~1,直到我处于正确的提交状态。我也有一大堆未版本化的文件(我在/usr/Local 中修改了文件权限) ,所以我做了一个 git clean -f -d,删除了所有未版本化的文件和目录,让我回到我做任何修改之前开始的地方。

酿造更新错误可以通过以下方法修复:

sudo chown -R $USER:admin /usr/local
cd /usr/local
git reset --hard origin/master
brew update

Https://github.com/homebrew/homebrew/issues/19140

Take a look at this tutorial here: http://ryantvenge.com/2014/09/ruby-homebrea-yosemite/

我成功了!

注意: 只有在你完全失败的情况下才会这样做,因为这是非常危险的

作为一个例子,我不断得到

$sudo ln-s Current 1.8

$酿酒更新

/usr/local/Library/brew.rb:18:in ': undefined method help?’ for [“update”]:Array (NoMethodError)

我只是得到这个... (不管是什么命令,只要用这个命令切换“ update”即可) 我解决了这个问题,要求一个伙伴 /usr/local文件夹。然后我备份了我的 /usr/local文件夹。

Sudo mv/usr/local/usr/local.orig

I then moved his /usr/local to mine

sudo mv ~/Downloads/local /usr/local

注意: 您可能会丢失一些数据,所以请确保进行备份。

我在使用软件包管理器安装 Ruby 时遇到了问题。公平地说,我承认对这些程序没有什么经验,也没有像其他大多数应急人员那样努力深入挖掘。我比较懒惰,更喜欢使用二进制安装程序,可用于大多数 opsys 选择和许多软件包。不幸的是,露比似乎没有提供。

我发现 Ruby-build 很容易安装(独立的——不是插件) ,它从源代码构建 Ruby,没有错误,并把它放在我想要的地方。

Bingo-easy:)对于我们这些面临说服挑战的包经理来说,这看起来是一个不错的选择。

Charlie

我把它修正如下:

  1. sudo chown -R $(whoami):admin /usr/local
  2. cd $(brew --prefix) && git fetch origin && git reset --hard origin/master