4

当我尝试运行“rake test”时出现此错误:

avery@ubuntu:~/rails_projects/depot$ rake test
rake aborted!
You have already activated rake 10.0.1, but your Gemfile requires rake 10.0.0. Using bundle exec may solve this.
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:31:in `block in setup'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:17:in `setup'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler.rb:116:in `setup'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/setup.rb:7:in `<top (required)>'
/home/avery/rails_projects/depot/config/boot.rb:6:in `<top (required)>'
/home/avery/rails_projects/depot/config/application.rb:1:in `<top (required)>'
/home/avery/rails_projects/depot/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

当我尝试运行“bundle exec rake”时,我得到:

rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `require'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `each'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `block in require'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `each'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `require'
/home/avery/.rvm/gems/ruby-1.9.3-p327/gems/bundler-1.2.2/lib/bundler.rb:128:in `require'
/home/avery/rails_projects/depot/config/application.rb:7:in `<top (required)>'
/home/avery/rails_projects/depot/Rakefile:5:in `require'
/home/avery/rails_projects/depot/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

我怎样才能解决这个问题?

4

5 回答 5

16

你可能rake 10.0.0在你的Gemfile.lock.

删除Gemfile.lock可能会解决问题。

于 2012-11-16T14:25:51.120 回答
5

对于问题的第一部分:我遇到了同样的问题并通过以下方式解决了它:

gem regenerate_binstubs

在那之后

gem -V

再次显示 10.0.0。

于 2012-11-15T22:10:36.840 回答
3

第一个问题的答案

在您的Gemfile中,通过以下方式明确设置最新的 rake 版本

gem 'rake', '~> 10.0.1'

然后运行

$ bundle update rake

第二个问题的答案

把它放在你的Gemfile并运行 bundle install

gem 'therubyracer'
于 2012-11-16T10:50:26.990 回答
2

对于问题的第二部分,您只需将其添加到您的 Gemfile 中:

gem 'therubyracer'
于 2012-11-15T15:25:31.093 回答
0

If you've specified a rake version in your Gemfile that your project requires, eg:

gem 'rake', '~> 10.0.0'

Try installing it again

bundle install
于 2012-12-07T21:32:05.727 回答