我正在尝试从TestFirst.org学习Ruby课程。它要求您导航到包含练习的文件夹,运行rake,然后更正它发现的源代码中的任何错误。当我在第一个练习的文件夹中运行rake时,会出现此错误:
rake aborted!
Could not find rspec (~> 2) amongst [diff-lcs-1.2.5, rspec-3.0.0, rspec-core-3.0.0,
rspec- expectations-3.0.0, rspec-mocks-3.0.1, rspec-support-3.0.0]
/home/jayson/Desktop/learn_ruby/Rakefile:2:in `<top (required)>'
(See full trace by running task with --trace)
这是否意味着它只适用于旧版本的rspec或其他东西?用--trace运行rake给了我:
rake aborted!
Could not find rspec (~> 2) amongst [diff-lcs-1.2.5, rspec-3.0.0,
rspec-core-3.0.0, rspec-expectations-3.0.0, rspec-mocks-3.0.1, rspec-support-3.0.0]
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs'
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
/usr/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
/home/jayson/Desktop/learn_ruby/Rakefile:2:in `<top (required)>'
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:25:in `load'
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:25:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:589:in `raw_load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:89:in `block in load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:160:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:88:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:72:in `block in run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:160:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:70:in `run'
/usr/bin/rake:27:in `<main>'
如何让rake命令正常工作?我在Ubuntu 14.04中使用Terminal,使用Ruby 1.9.3,RubyGems 1,8.23和Rspec 3.0.0。提前谢谢。
答案 0 :(得分:2)
我遇到了同样的问题,sudo gem install -v '<3.0.0' rspec
确实有效,但只有在我用gem uninstall rspec
卸载新版本后才能使用。
首先没有卸载,只有更高版本保持活动状态,问题仍将继续。
答案 1 :(得分:0)
gem install rspec -v 2.9.0
这是因为:
Could not find rspec (~> 2)
在您的计算机上安装的rspec
版本为:rspec-3.0.0
来源:RubyGems