在OS X Yosemite上修复Ruby

时间:2014-06-04 22:56:53

标签: ruby-on-rails ruby rvm osx-yosemite

我收到以下错误:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/yaml.rb:4:in `<top (required)>':                                                                           
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- psych (LoadError)
  from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/yaml.rb:5:in `<top (required)>'
  from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/bin/hub:190:in `<main>'

我已尝试过有关libyaml和psych的Stack Overflow上的建议。但是,其中许多需要rvm命令,它们会返回以下错误:

rvm reinstall 2.0
/Users/richardburton/.rvm/src/ruby-2.0.0-p247 has already been removed.
Removing /Users/richardburton/.rvm/rubies/ruby-2.0.0-p247 - please wait
Error running '__rvm_rm_rf /Users/richardburton/.rvm/rubies/ruby-2.0.0-p247',
please read /Users/richardburton/.rvm/log/1401921952_ruby-2.0.0-p247/remove.rubies.log
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-2.0.0-p247.

显然现阶段有一个rvm二进制文件。关于如何启动和运行Ruby 2.0的任何提示或建议都将非常感激。

谢谢!

3 个答案:

答案 0 :(得分:0)

您收到的第一个错误是引用您的系统ruby,并且您正在使用rvm重新安装。尝试运行which ruby。最有可能的是,可以通过更新路径来解决此问题。我不建议重新安装系统ruby,所以我绝对建议让任何导致第一个错误的东西与rvm一起使用。

如果仍然无法正常工作,我接下来尝试使用rbenv而不是rvm。我个人是rbenv的粉丝,我的Ruby使用它没有任何问题。它非常容易启动和运行,并且可能是一个很好的临时解决方案。

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile # or whichever profile you are using
$ source ~/.bash_profile                           # or whichever profile you are using
$ rbenv install <version number>
$ rbenv global <version number>

链接到rbenv信息:

rbenv:https://github.com/sstephenson/rbenv

ruby​​-build:https://github.com/sstephenson/ruby-build#readme

答案 1 :(得分:0)

rvm package install libyaml
rvm reinstall 1.9.3 --with-libyaml-dir=/home/rails/.rvm/usr

我有同样的错误,这对我有用

来源:https://serverfault.com/questions/442150/how-to-fix-ruby-installation-is-missing-psych-for-yaml-output-on-centos

答案 2 :(得分:-1)

我遇到了同样的问题,我尝试了两种解决方案:

1)使用ruby-build构建带有前缀/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr的ruby-2.0-p451 - &gt;不工作(GOT SEGMENTATION FAULT)

2)替换为OSX 10.9附带的库存版本---&gt; WORKS !!

请参阅我的代码段,了解如何在此处执行此操作:https://gist.github.com/joneslee85/73ece54ba5b3a17e8bb2

现在我可以去睡觉了。祝你好运!