【问题标题】:Error loading rubygems加载 ruby​​gems 时出错
【发布时间】:2011-06-23 01:53:15
【问题描述】:

在需要加载 ruby​​gems(来自 config/boot.rb 文件)的操作(rspec 相关)期间,我收到以下错误消息:

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

我在 SO 上查找了这个错误,发现了以下主题: ruby gem not found although it is installedno such file to load -- rubygems (LoadError)

但是他们都提到问题可能来自机器上存在多个版本的 ruby​​。实际上就是这样,所以我决定使用 RVM 重新安装 ruby​​ 和 rails。但是我还是有同样的问题!

附加信息:

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

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails ruby rubygems rspec


    【解决方案1】:

    所以我显然通过使用命令rspec 而不是spec 解决了我的问题。如果有人可以解释幕后实际发生的事情,那就太好了!

    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
    

    【讨论】:

    • 您尝试使用哪个版本的 rspec? spec 已被弃用,因此您可能会尝试使用旧版本的 rspec。
    • 好 :) 如果您安装了任何旧的 rspec gem,我会尝试删除。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多