Trying to use rspec, but getting an error that rspec-core 2.2.1 has been activated, but my Gemfile requires rspec-core 2.1.0
I've update my gems. I've created a sample Rails app and have the following in my Gemfile:
开发者_开发技巧source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development do
gem 'rspec-rails'
end
group :test do
gem 'rspec'
gem 'webrat', '0.7.1'
end
However, when I run 'rspec spec/', I get the following message:
/home/jeff/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.7/lib/bundler/runtime.rb:27:in `block in setup':
You have already activated rspec-core 2.2.1, but your Gemfile requires rspec-core 2.1.0.
Consider using bundle exec. (Gem::LoadError)
try using bundle update rspec
and bundle update rspec-rails
. your Gemfile.lock
file, located in the root directory, is probably specifying a version number for each gem.
A combination of Sam Ritchie's and Alexey's solutions helped me here. In the end I had to:
bundle update rspec
bundle update rspec-rails
sudo gem uninstall rspec-mocks
sudo gem uninstall rspec-expectations
sudo gem uninstall rspec-core
(prompts for versions if none are entered)
As Alexey says, use this to see which versions are too high:
gem list rspec
(Would vote for you Alexey, but apparently I don't have enough of a "reputation" on stack.)
I got the same issue right now. to fix it try to:
sudo gem uninstall rspec-core -v 2.2.1
bundle update rspec-core
You may need to do that for other dependent gems (like rspec, rspec-rails etc). Use the command to see the candidates:
gem list rspec
Rails noob here ... I'm following Michael Hartl's brilliant tutorial ... stuck at layouts
Tried changing rspec & webrat versions as mentioned in this post about rspec/webrat errors to no avail.
For rspec v2.1.0 I get the same error as @user338413.
rspec -v returns 2.2.1
dev machine running ubuntu 10.04
resolved....works with rspec 2.2.0 + webrat 0.7.1, although I would still like to know why
This is easily solved:
bundle exec rspec
will force bundler to use the gem version you are requiring for your project, ignoring system-wide settings.
change the version number from 2.1.0 to 2.2.1 in Gemfile.lock
精彩评论