我试图运行Test First Ruby(来自http://testfirst.org/的Ruby教程)。我必须完成练习作为作业的一部分。
我安装了Ruby 2.0.0和rspec(它需要)。但是当我尝试跑步时#ra;"从命令行窗口,我收到一条错误消息:
rake aborted!
Gem::LoadError: Could not find 'rspec' (~> 2) - did find: [rspec-3.0.0]
C:/Users/Motiur/Desktop/test-first-ruby-master/Rakefile:2:in '<top (required)>'
(See full trace by running task with --trace)
按照建议使用跟踪运行时:
C:\Users\Motiur\Desktop\test-first-ruby-master\00_hello>rake --trace
(in C:/Users/Motiur/Desktop/test-first-ruby-master)
rake aborted!
Gem::LoadError: Could not find 'rspec' (~> 2) - did find: [rspec-3.0.0]
C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs'
C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
C:/Users/Motiur/Desktop/test-first-ruby-master/Rakefile:2:in `<top (required)>'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/rake_module.rb:28:i
n `load'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/rake_module.rb:28:i
n `load_rakefile'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:687:
in `raw_load_rakefile'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:94:i
n `block in load_rakefile'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:176:
in `standard_exception_handling'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:93:i
n `load_rakefile'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:77:i
n `block in run'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:176:
in `standard_exception_handling'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:75:i
n `run'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rake-10.3.2/bin/rake:33:in `<top (requir
ed)>'
C:/Ruby200-x64/bin/rake:23:in `load'
C:/Ruby200-x64/bin/rake:23:in `<main>'
我尝试重新安装Ruby&amp; Rspec,我甚至尝试了两台不同的计算机,但我得到了同样的错误。也许我不正确地安装它?请帮忙。谢谢!
答案 0 :(得分:1)
在运行rake
之前,您应该运行bundle install
。这只需要做一次。如果在运行bundle
时未找到命令,请安装bundler gem。这可以使用gem install bundler
完成。
有关您的信息,bundle
是来自bundler gem的命令。在红宝石中,宝石是包装。它们通常包含库,但有时它们包含工具和其他漂亮的东西。 Bundler用于管理依赖项。
要使用bundler,您必须编写一个Gemfile(一个名为Gemfile的实际文件,放在应用程序的根目录中)。此Gemfile定义了应用程序所需的所有gem。运行bundle install
时,它会查看Gemfile并安装所需的所有gem。
据我所知,您所关注的教程已经附带了一个Gemfile。您需要做的只是运行bundle install
。