2011-02-07 25 views
1

在操作期間(rspec的相關),需要裝載的RubyGems(從配置/的boot.rb文件),我得到了以下錯誤消息:錯誤加載RubyGems的

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

但是他們都mentionned,問題可能來自在機器上紅寶石的多個版本是否存在等。事實上,情況就是這樣,所以我決定使用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 

任何想法?

回答

1

所以我顯然通過使用命令rspec而不是spec來解決我的問題。如果有人能夠解釋幕後實際發生的事情,那會很棒!

[email protected] ~/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 

[email protected] ~/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 
+1

您試圖使用哪種版本的rspec? `spec`已被棄用,所以你可能試圖使用舊版本的rspec。 – raidfive 2011-02-07 23:39:52