简体   繁体   English

在 OS X Yosemite 上修复 Ruby

[英]Fixing Ruby on OS X Yosemite

I am getting the following error:我收到以下错误:

/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>'

I've tried the suggestions on Stack Overflow which are related libyaml and psych.我已经尝试了有关与 libyaml 和 psych 相关的 Stack Overflow 的建议。 However, many of those require rvm commands which return the following error:但是,其中许多需要 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.

Obviously there are a rvm binaries available at this stage.显然,现阶段有可用的 rvm 二进制文件。 Any tips or suggestions on how I can get Ruby 2.0 up and running would be much appreciated.关于如何启动和运行 Ruby 2.0 的任何提示或建议将不胜感激。

Thanks!谢谢!

The first error you are receiving is referencing your system ruby, and you're reinstalling with rvm.您收到的第一个错误是引用您的系统 ruby​​,并且您正在使用 rvm 重新安装。 Try running which ruby .尝试运行which ruby Most likely this can be fixed by updating your path.这很可能可以通过更新您的路径来解决。 I wouldn't recommend reinstalling the system ruby, so I'd definitely recommend getting whatever was causing the first error to work with rvm.我不建议重新安装系统 ruby​​,所以我绝对建议获取导致第一个错误的任何内容与 rvm 一起使用。

If that still isn't working, I'd next try using rbenv instead of rvm.如果这仍然不起作用,我接下来会尝试使用 rbenv 而不是 rvm。 I'm personally a fan of rbenv and have had no issues with my Ruby using it.我个人是 rbenv 的粉丝,我的 Ruby 使用它没有任何问题。 It's super easy to get up and running, and could be a good temp fix.它非常容易启动和运行,并且可能是一个很好的临时修复。

$ 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>

Links to rbenv info: rbenv 信息的链接:

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

ruby-build: https://github.com/sstephenson/ruby-build#readme红宝石构建: https : //github.com/sstephenson/ruby-build#readme

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

I had the same error and this worked for me我有同样的错误,这对我有用

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

I've bumped into the same issue and I have tried two solutions:我遇到了同样的问题,我尝试了两种解决方案:

1) Using ruby-build to build ruby-2.0-p451 with prefix /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr --> DOES NOT WORK (GOT SEGMENTATION FAULT) 1) 使用 ruby​​-build 构建前缀为 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr --> 的 ruby​​-2.0-p451 --> 不起作用(GOT SEGMENTATION FAULT)

2) Replace with the stock version shipped with OSX 10.9 ---> WORKS!! 2) 替换为 OSX 10.9 附带的库存版本 ---> WORKS!!

Please see my snippet on how to do it here: https://gist.github.com/joneslee85/73ece54ba5b3a17e8bb2请在此处查看有关如何执行此操作的片段: https : //gist.github.com/joneslee85/73ece54ba5b3a17e8bb2

Now I can go to sleep.现在我可以去睡觉了。 Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM