简体   繁体   English

加载rubygems时出错

[英]Error loading rubygems

During an operation (rspec related) that required loading rubygems (from config/boot.rb file) I got the following error message: 在需要加载rubygems的操作(与rspec相关)中(从config / boot.rb文件),我收到以下错误消息:

~/config/boot.rb:1:in `require': no such file to load -- rubygems (LoadError)
~/config/boot.rb:1
    from ~/config/application.rb:1:in `require'
    from ~/config/application.rb:1
    from ~/config/environment.rb:2:in `require'
    from ~/config/environment.rb:2
    from ~/spec/spec_helper.rb:3:in `require'
    from ~/spec/spec_helper.rb:3
    from ~/spec/models/user_spec.rb:1:in `require'
    from ~/spec/models/user_spec.rb:1
    from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:15:in `load'
    from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:15:in `load_files'
    from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:14:in `each'
    from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:14:in `load_files'
    from /usr/lib/ruby/1.8/spec/runner/options.rb:132:in `run_examples'
    from /usr/lib/ruby/1.8/spec/runner/command_line.rb:9:in `run'
    from /usr/bin/spec:3

I looked for this error on SO and found the following topics: ruby gem not found although it is installed and no such file to load -- rubygems (LoadError) 我在SO上查找此错误,并发现以下主题: 尽管已安装ruby gem,但未找到 要加载的文件-rubygems(LoadError)

However they both mentionned that the problem could come from the existance of multiple versions of ruby on the machine. 但是他们俩都提到问题可能来自机器上存在多个版本的红宝石。 Actually that was the case, so I decided to run a fresh installation of ruby and rails using RVM. 实际上就是这种情况,因此我决定使用RVM运行全新的红宝石和导轨安装。 But I still have the same problem! 但是我仍然有同样的问题!

Additional information: 附加信息:

which ruby
/usr/local/rvm/rubies/ruby-1.9.2-p136/bin/ruby

which rails
/usr/local/rvm/gems/ruby-1.9.2-p136/bin/rails

which gem
/usr/local/rvm/rubies/ruby-1.9.2-p136/bin/gem

gem --version
1.5.0

ls /usr/lib/ruby
1.8  1.9.1  gems

Any idea? 任何想法?

So I apparently solved my problem by using the command rspec instead of spec . 因此,我显然通过使用命令rspec而不是spec解决了我的问题。 If someone can explain what is actually going on behind the scene, it would be great! 如果有人可以解释幕后实际发生的事情,那就太好了!

amokrane@san-francisco ~/Documents/prog/web/learning_rails/forecaster/spec $ spec models/user_spec.rb 
/home/amokrane/Documents/prog/web/learning_rails/forecaster/config/boot.rb:1:in `require': no such file to load -- rubygems (LoadError)
    from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/boot.rb:1
    from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/application.rb:1:in `require'
    from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/application.rb:1
    from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/environment.rb:2:in `require'
    from /home/amokrane/Documents/prog/web/learning_rails/forecaster/config/environment.rb:2
    from /home/amokrane/Documents/prog/web/learning_rails/forecaster/spec/spec_helper.rb:3:in `require'
    from /home/amokrane/Documents/prog/web/learning_rails/forecaster/spec/spec_helper.rb:3
    from /home/amokrane/Documents/prog/web/learning_rails/forecaster/spec/models/user_spec.rb:1:in `require'
    from /home/amokrane/Documents/prog/web/learning_rails/forecaster/spec/models/user_spec.rb:1
    from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:15:in `load'
    from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:15:in `load_files'
    from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:14:in `each'
    from /usr/lib/ruby/1.8/spec/runner/example_group_runner.rb:14:in `load_files'
    from /usr/lib/ruby/1.8/spec/runner/options.rb:132:in `run_examples'
    from /usr/lib/ruby/1.8/spec/runner/command_line.rb:9:in `run'
    from /usr/bin/spec:3

amokrane@san-francisco ~/Documents/prog/web/learning_rails/forecaster/spec $ rspec models/weather_spec.rb 
F

Failures:

  1) Weather should be valid
     Failure/Error: @weather = Weather.new
     ActiveRecord::StatementInvalid:
       Could not find table 'weathers'
     # ./models/weather_spec.rb:6:in `new'
     # ./models/weather_spec.rb:6:in `block (2 levels) in <top (required)>'

Finished in 0.11124 seconds
1 example, 1 failure

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

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