views:

827

answers:

4

If i define a few gems in my config/environments/test.rb file like this:

config.gem "rspec" config.gem "rspec-rails" config.gem "mocha"

and then run 'rake gems:install RAILS_ENV=test'

I get the following error:

Missing these required gems: mocha

Run rake gems:install to install the missing gems.

however if I run rake gems:install like it says it will continue to recurse like this forever.

How do I actually get the gems to install using rake (not gem install)?

thanks!

+1  A: 

I wonder, is there a reference to something from the mocha gem in your rake file or environment.rb file? I've seen issues like this before and it presents as this type of problem.

Try installing mocha 'manually' with...

gem install mocha

Then see if you can run rake gems:install.

hopeless
A: 

I found this was a GEM_PATH issue. Basically, rails can't find the gems you've installed and even though they're there, they're completely invisible. A bit weird, but hey.

On dreamhost I had to configure the line:

ENV['GEM_PATH'] = '/home/<my_account>/.gems:/usr/lib/ruby/gems/1.8/gems'

in config/environment.rb

but on my dev box this doesn't work for me and has to be removed entirely. YMMV but I'd suggest that's a good place to start looking.

Taryn East
A: 

I ran into this problem as well, and followed the directions here to resolve it. Specifically, deleting and regenerating lib/tasks/rspec.rake is pretty crucial. Also, adding

:lib => false

to

config.gem "rspec", :lib => false, :version => ">= 1.2.0"

helped.

alalonde
A: 

Which platform are you using? If it it window then

Execute Below command and its works

gem install mocha --platform=mswin32

Amit