"Missing these required gems: rspec-rails" in ruby 1.9

i get the above error when running rake.
I tried switching rails 2.3.3 with 2.3.2 but it didn’t help.

here are my gems:
actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
builder (2.1.2)
cucumber (0.3.98)
diff-lcs (1.1.2)
hoe (2.3.3)
nokogiri (1.3.3)
polyglot (0.2.8)
rack (1.0.0)
rails (2.3.2)
rake (0.8.7)
rspec (1.2.8)
rspec-rails (1.2.7.1)
rubyforge (1.0.4)
term-ansicolor (1.0.4)
test-unit (1.2.3)
treetop (1.3.0)
webrat (0.5.3)

and here is the error after typing rake:

no such file to load – rspec-rails
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/polyglot-0.2.8/lib/
polyglot.rb:68:in require' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/polyglot-0.2.8/lib/ polyglot.rb:68:inrequire’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:156:in block in require' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:521:innew_constants_in’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:156:in require' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/rails/ gem_dependency.rb:179:inload’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/
initializer.rb:305:in block in load_gems' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/ initializer.rb:305:ineach’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/
initializer.rb:305:in load_gems' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/ initializer.rb:162:inprocess’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/
initializer.rb:113:in run' /home/oren/nutrition/config/environment.rb:9:in<top (required)>’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:156:in require' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:156:inblock in require’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:521:in new_constants_in' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:156:inrequire’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/tasks/
misc.rake:4:in block in <top (required)>' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 636:incall’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
636:in block in execute' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 631:ineach’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
631:in execute' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 597:inblock in invoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:in
mon_synchronize' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 590:ininvoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
607:in block in invoke_prerequisites' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 604:ineach’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
604:in invoke_prerequisites' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 596:inblock in invoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:in
mon_synchronize' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 590:ininvoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
607:in block in invoke_prerequisites' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 604:ineach’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
604:in invoke_prerequisites' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 596:inblock in invoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:in
mon_synchronize' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 590:ininvoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
607:in block in invoke_prerequisites' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 604:ineach’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
604:in invoke_prerequisites' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 596:inblock in invoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:in
mon_synchronize' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 590:ininvoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
607:in block in invoke_prerequisites' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 604:ineach’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
604:in invoke_prerequisites' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 596:inblock in invoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:in
mon_synchronize' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 590:ininvoke_with_call_chain’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
583:in invoke' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 2051:ininvoke_task’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
2029:in block (2 levels) in top_level' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 2029:ineach’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
2029:in block in top_level' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 2068:instandard_exception_handling’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
2023:in top_level' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 2001:inblock in run’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
2068:in standard_exception_handling' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 1998:inrun’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake:
31:in <top (required)>' /opt/ruby/bin/rake:19:inload’
/opt/ruby/bin/rake:19:in <main>' no such file to load -- rspec-rails /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/polyglot-0.2.8/lib/ polyglot.rb:68:inrequire’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/polyglot-0.2.8/lib/
polyglot.rb:68:in require' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:156:inblock in require’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:521:in new_constants_in' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:156:inrequire’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/rails/
gem_dependency.rb:179:in load' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/ initializer.rb:305:inblock in load_gems’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/
initializer.rb:305:in each' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/ initializer.rb:305:inload_gems’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/
initializer.rb:167:in process' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/ initializer.rb:113:inrun’
/home/oren/nutrition/config/environment.rb:9:in <top (required)>' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:156:inrequire’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:156:in block in require' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/ active_support/dependencies.rb:521:innew_constants_in’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:156:in require' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/tasks/ misc.rake:4:inblock in <top (required)>’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
636:in call' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 636:inblock in execute’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
631:in each' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 631:inexecute’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
597:in block in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:inmon_synchronize’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
590:in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 607:inblock in invoke_prerequisites’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
604:in each' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 604:ininvoke_prerequisites’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
596:in block in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:inmon_synchronize’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
590:in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 607:inblock in invoke_prerequisites’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
604:in each' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 604:ininvoke_prerequisites’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
596:in block in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:inmon_synchronize’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
590:in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 607:inblock in invoke_prerequisites’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
604:in each' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 604:ininvoke_prerequisites’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
596:in block in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:inmon_synchronize’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
590:in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 607:inblock in invoke_prerequisites’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
604:in each' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 604:ininvoke_prerequisites’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
596:in block in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/1.9.1/monitor.rb:190:inmon_synchronize’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
590:in invoke_with_call_chain' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 583:ininvoke’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
2051:in invoke_task' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 2029:inblock (2 levels) in top_level’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
2029:in each' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 2029:inblock in top_level’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
2068:in standard_exception_handling' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 2023:intop_level’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
2001:in block in run' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb: 2068:instandard_exception_handling’
/opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:
1998:in run' /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake: 31:in<top (required)>’
/opt/ruby/bin/rake:19:in load' /opt/ruby/bin/rake:19:in
Missing these required gems:
rspec-rails

You’re running:
ruby 1.9.1.243 at /opt/ruby-1.9.1-p243/bin/ruby
rubygems 1.3.5 at /home/oren/.gem/ruby/1.9.1, /opt/ruby-1.9.1-p243/
lib/ruby/gems/1.9.1

thanks!

It’s exactly what it says. Do:

gem install rspec-rails

(or if you’re on a Mac, sudo gem install rspec-rails).

i already have it installed!

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
builder (2.1.2)
cucumber (0.3.98)
diff-lcs (1.1.2)
hoe (2.3.3)
nokogiri (1.3.3)
polyglot (0.2.8)
rack (1.0.0)
rails (2.3.2)
rake (0.8.7)
rspec (1.2.8)
rspec-rails (1.2.7.1)
rubyforge (1.0.4)
term-ansicolor (1.0.4)
test-unit (1.2.3)
treetop (1.3.0)
webrat (0.5.3)

change the config.gem lines for rspec/rspec-rails in your test.rb
to:

config.gem “rspec”, :lib => false
config.gem “rspec-rails”, :lib => false

that should solve your problem

i already have it installed!

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
builder (2.1.2)
cucumber (0.3.98)
diff-lcs (1.1.2)
hoe (2.3.3)
nokogiri (1.3.3)
polyglot (0.2.8)
rack (1.0.0)
rails (2.3.2)
rake (0.8.7)
rspec (1.2.8)
rspec-rails (1.2.7.1)
rubyforge (1.0.4)
term-ansicolor (1.0.4)
test-unit (1.2.3)
treetop (1.3.0)
webrat (0.5.3)

thank you, it works!
what is the reason for this error?

rails tries to require ‘rspec’ and ‘rspec-rails’. but the rspec
library is ‘spec’ and the rspec-rails is ‘spec/rails’. :lib =>
‘spec’ / :lib => ‘spec/rails’ would work too,
but since you only want to load the rspec/rails libs when you are
actually running specs, and you usually require ‘spec/rails’ in your
spec_helper.rb anyway, you can use :lib => false so rails doesn’t
require the rspec libs at all.

thank you!