[英]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:
我已经创建了一个示例Rails应用程序并在我的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: 但是,当我运行'rspec spec /'时,我收到以下消息:
/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
. 尝试使用
bundle update rspec
和bundle update rspec-rails
。 your Gemfile.lock
file, located in the root directory, is probably specifying a version number for each gem. 位于根目录中的
Gemfile.lock
文件可能指定了每个gem的版本号。
A combination of Sam Ritchie's and Alexey's solutions helped me here. Sam Ritchie和Alexey的解决方案相结合,帮助了我。 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: 正如Alexey所说,使用它来查看哪些版本太高:
gem list rspec
(Would vote for you Alexey, but apparently I don't have enough of a "reputation" on stack.) (会投票给你Alexey,但显然我在筹码上没有足够的“声望”。)
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). 您可能需要为其他依赖宝石(如rspec,rspec-rails等)执行此操作。 Use the command to see the candidates:
使用该命令查看候选人:
gem list rspec
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. 将强制捆绑程序使用您的项目所需的gem版本,忽略系统范围的设置。
在Gemfile.lock中将版本号从2.1.0更改为2.2.1
Rails noob here ... I'm following Michael Hartl's brilliant tutorial ... stuck at layouts Rails noob here ...我正在关注Michael Hartl的精彩教程......坚持布局
Tried changing rspec & webrat versions as mentioned in this post about rspec/webrat errors to no avail. 尝试更改rspec和webrat版本,如本文中提到的关于rspec / webrat错误无济于事。
For rspec v2.1.0 I get the same error as @user338413. 对于rspec v2.1.0,我得到与@ user338413相同的错误。
rspec -v returns 2.2.1 rspec -v返回2.2.1
dev machine running ubuntu 10.04 开发机器运行ubuntu 10.04
resolved....works with rspec 2.2.0 + webrat 0.7.1, although I would still like to know why 已解决....适用于rspec 2.2.0 + webrat 0.7.1,虽然我仍然想知道原因
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.