无法加载此类文件 - ruby​​gems.rb

时间:2014-08-15 14:13:25

标签: ruby-on-rails ruby terminal rvm

要打开这个项目(狂欢),我需要使用ruby-2.1.2。我安装了ruby-2.1.0和ruby-2.1.2,但我认为2.1.2版本因某些原因而损坏,我似乎无法使用它。

|~/desktop/ix/projects/revel> rvm use 2.1.2
Using /Users/lianoosh/.rvm/gems/ruby-2.1.2
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
    from <internal:gem_prelude>:1:in `<compiled>'

|~/desktop/ix/projects/revel> gem list
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
    from <internal:gem_prelude>:1:in `<compiled>'

|~/desktop/ix/projects/revel> gem update --system 
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
    from <internal:gem_prelude>:1:in `<compiled>'

当我尝试卸载以重新安装时,我得到:

|~/desktop/ix/projects/revel> rvm uninstall 2.1.2
ruby-2.1.2 - #removing rubies/ruby-2.1.2............................................................................................................................|
Error running '__rvm_rm_rf /Users/lianoosh/.rvm/rubies/ruby-2.1.2',
showing last 15 lines of /Users/lianoosh/.rvm/log/1408110977_ruby-2.1.2/remove.rubies.log
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.1/test/zoneinfo: Permission denied
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.1/test: Permission denied
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.1/tzinfo.gemspec: Permission denied
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.1: Directory not empty
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems: Directory not empty
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0: Directory not empty
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2/lib/ruby/gems: Directory not empty
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2/lib/ruby: Directory not empty
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2/lib: Directory not empty
rm: /Users/lianoosh/.rvm/rubies/ruby-2.1.2: Directory not empty
++ typeset ret=1
++ rvm_debug '__rvm_rm_rf error removing target dir '\''/Users/lianoosh/.rvm/rubies/ruby-2.1.2'\''.'
++ ((  0  ))
++ return 0
++ return 1

然后:

|~/desktop/ix/projects/revel> rvm list

rvm rubies

   ruby-2.1.0 [ x86_64 ]
=* ruby-2.1.2 [ missing bin/ruby ]

# => - current
# =* - current && default
#  * - default

所以当我尝试重新安装时,我得到:

Already installed ruby-2.1.2.
To reinstall use:

    rvm reinstall ruby-2.1.2

当我这样做时,我得到一堆许可被拒绝的消息和目录不是空的,然后回到我开始的地方。 也:

Empty path passed to certificates update, functions stack: requirements_osx_update_openssl_cert_run rvm_requiremnts_fail_or_run_action __rvm_osx_ssl_certs_ensure_for_ruby __rvm_osx_ssl_certs_ensure_for_ruby_except_jruby external_import_setup external_import main

请帮忙!

3 个答案:

答案 0 :(得分:12)

试试这个:

rvm fix-permissions

rvm reinstall 2.1.2

答案 1 :(得分:3)

即使我今天遇到这个问题,但是再次安装Ruby对我来说似乎并不合适,因为从昨天开始,一切都运行良好

根据错误,我刚刚更新了RubyGem,这对我来说效果很好。

gem install rubygems-update

update_rubygems

答案 2 :(得分:0)

破坏红宝石的问题,在RVM的情况下可以用一种非常简单但不整齐的方法解决 - rvm重新安装你需要删除RVM以及所有红宝石。
请参考这article