如何让 Ruby / Homebrew / RVM 在 Yosemite 上工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24225959/
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
How to get Ruby / Homebrew / RVM to work on Yosemite?
提问by eden
After installing Yosemite, I was unable to run brew or ruby.
安装 Yosemite 后,我无法运行 brew 或 ruby。
I was getting this error on brew update:
我在 brew 更新时收到此错误:
/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
getting this error on irb:
在 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 `'
回答by raz0r
This error can easily be fixed in the following steps:
可以通过以下步骤轻松修复此错误:
1) Open terminal
1) 打开终端
2) Type nano /usr/local/Library/brew.rb
2) 类型 nano /usr/local/Library/brew.rb
3) In the first line change “1.8″ to “Current”, so it should look like this:
3) 在第一行中将“1.8”改为“Current”,所以它应该是这样的:
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
via http://blog.ic3man.gr/2014/06/homebrew-ruby-bad-interpreter-no-such-file-or-directory/
通过http://blog.ic3man.gr/2014/06/homebrew-ruby-bad-interpreter-no-such-file-or-directory/
回答by Jason R
I updated to Yosemite and later found out brewwas broken.
我更新到优胜美地,后来发现brew坏了。
/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
If you haven't made any changes to brew yet, here is what I recommend. Otherwise read further below.
如果您还没有对 brew 进行任何更改,那么这就是我的建议。否则请阅读下文。
cd /System/Library/Frameworks/Ruby.framework/Versions/sudo ln -s Current 1.8brew updatesudo unlink 1.8
cd /System/Library/Frameworks/Ruby.framework/Versions/sudo ln -s Current 1.8brew updatesudo unlink 1.8
Already made changes to brew files and stuck in a git mess?
已经对 brew 文件进行了更改并陷入了 git 混乱?
I tried to edit /usr/local/Library/brew.rbbut the local change to my git repo was preventing brew updatefrom 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.
我尝试编辑,/usr/local/Library/brew.rb但对我的 git 存储库的本地更改阻止brew update了更新。我尝试了本页面和其他网站上提到的其他一些解决方案,但最终还是搞砸了,我想做的就是撤消我为 brew 所做的一切。
I committed my change but it made things worse. Eventually I had to undo my commits and git reset --hard HEAD~1until I was at the right commit-ish. I had a mess of unversioned files too (I changed files permissions in /usr/Local) so I did a git clean -f -dwhich removed all unversioned files and directories and got me back to where I started before I made any changes.
我做出了改变,但这让事情变得更糟。最终我不得不撤消我的提交,git reset --hard HEAD~1直到我处于正确的提交状态。我也有一堆未版本化的文件(我更改了 /usr/Local 中的文件权限),所以我git clean -f -d删除了所有未版本化的文件和目录,并在进行任何更改之前让我回到了开始的位置。
回答by eden
Steps to fix it:
修复它的步骤:
Install command line tools for Xcode 6
Reinstall brew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Once brew is installed, rvm will work:
rvm install ruby
为 Xcode 6 安装命令行工具
重新安装酿造:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"安装 brew 后,rvm 将工作:
rvm install ruby
Worked for me, yahoo!
对我来说有效,雅虎!
回答by Otto
Editing the script means brew updatewon't work; there are local edits to tracked files which causes the git pullto fail.
编辑脚本意味着brew update不起作用;对跟踪文件进行了本地编辑,导致git pull失败。
I did this, which I suspect is cleaner:
我这样做了,我怀疑它更干净:
cd /usr/local/Library
git pull -q origin refs/heads/master:refs/remotes/origin/master
There are no complaints from brew doctor.
没有来自 的投诉brew doctor。
回答by Eli
This is a conglomeration from answers from other people's posts as well as a bit of digging on Google, but I figured I'd put it up so a complete answer is in one place. Specifically this gets things to work now, but also lets you do brew updates as normal and gets everything clean again.
这是来自其他人帖子的答案以及对谷歌的一些挖掘的集合,但我想我会把它放在一个地方,所以完整的答案是在一个地方。具体来说,这可以让事情现在开始工作,但也可以让您像往常一样进行 brew 更新并再次使一切变得干净。
- Open /usr/local/Library/brew.rb (emacs/vi/nano/whatever)
- Change the first line to read:
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0. You're just changing the "1.8" that was in that line to "Current" (make sure you keep the capital "C" otherwise git will get confused later). cd $(brew --repository)git add Library/brew.rbgit commit -m "upgrading to ruby 2.0"brew update(orsudo brew updateif your brew is setup to only do system changes with sudo)
- 打开 /usr/local/Library/brew.rb (emacs/vi/nano/whatever)
- 将第一行更改为:
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0. 您只是将该行中的“1.8”更改为“当前”(确保保留大写字母“C”,否则 git 稍后会混淆)。 cd $(brew --repository)git add Library/brew.rbgit commit -m "upgrading to ruby 2.0"brew update(或者sudo brew update如果您的 brew 设置为仅使用 sudo 进行系统更改)
Credit: a lot of this came from here, though I really recommend against doing git commit -amin your /usr/local folder.
信用:很多都来自这里,尽管我真的建议不要git commit -am在您的 /usr/local 文件夹中这样做。
回答by Vanessa B?hner
Like the one before said: 1) Change to current 2) install xcode 6
就像之前所说的那样:1)更改为当前版本 2)安装 xcode 6
If you now have further problems with brew and ruby this should help: Somehow brew needs ruby on version 1.8, so create the folder:
如果您现在对 brew 和 ruby 有进一步的问题,这应该会有所帮助:不知何故 brew 在 1.8 版上需要 ruby,因此创建文件夹:
sudo mkdir -p /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
and make a symlink:
并制作一个符号链接:
sudo ln -s /usr/bin/ruby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
回答by user790999
Take a look at this tutorial here: http://ryantvenge.com/2014/09/ruby-homebrea-yosemite/
在此处查看本教程:http: //ryantvenge.com/2014/09/ruby-homebrea-yosemite/
It worked for me!
它对我有用!
回答by Alex Lin
I fixed this as follows:
我解决了这个问题:
sudo chown -R $(whoami):admin /usr/localcd $(brew --prefix) && git fetch origin && git reset --hard origin/master
sudo chown -R $(whoami):admin /usr/localcd $(brew --prefix) && git fetch origin && git reset --hard origin/master
回答by abc123
Note: Only do the below if you end up in a completely failed state, as this is very DANGEROUS
注意:仅当您最终处于完全失败的状态时才执行以下操作,因为这是非常危险的
As an example I kept getting
作为一个例子,我不断得到
$ sudo ln -s Current 1.8
$ brew update
/usr/local/Library/brew.rb:18:in ': undefined method help?' for [“update”]:Array (NoMethodError)
$ sudo ln -s 当前 1.8
$ brew 更新
/usr/local/Library/brew.rb:18:in ':未定义的方法帮助?' 对于 [“更新”]:数组(NoMethodError)
I just get this…(no matter what command just switch out “update” with the command)
I solved the problem by asking for a buddies /usr/localfolder. I then made a backup of my /usr/localfolder.
我只是明白了……(不管是什么命令,只需用命令切换“更新”)我通过请求一个好友/usr/local文件夹解决了这个问题。然后我备份了我的/usr/local文件夹。
sudo mv /usr/local /usr/local.orig
须藤 mv /usr/local /usr/local.orig
I then moved his /usr/localto mine
然后我把他的搬到了/usr/local我的
sudo mv ~/Downloads/local /usr/local
须藤 mv ~/Downloads/local /usr/local
Note: You will likely lose some data so make sure to make a backup.
注意:您可能会丢失一些数据,因此请务必进行备份。
回答by gogasca
brew update error can be fixed with this:
brew 更新错误可以通过以下方式修复:
sudo chown -R $USER:admin /usr/local
cd /usr/local
git reset --hard origin/master
brew update

