我正在阅读一个教程并且遇到rake db:migrate和我的gemfile的问题。我知道有几个答案,这个问题在这里被问到(并且回答了很多)。但出于某种原因,我要么是在圈子里跑,也不是混乱,或者其他事情正在发生,我不知道。
我尝试过引用here的答案 - 我跑了
bundle exec run rake -T
这似乎不起作用。
然后我尝试按照引用here的dhh的建议,但我的系统说我没有要卸载的gemfile。这是我做的:
Z-Kidds-MacBook-Air:demo_app zkidd$ rake --version
rake, version 0.9.2.2
Z-Kidds-MacBook-Air:demo_app zkidd$ gem uninstall rake -v=0.9.2.2
INFO: gem "rake" is not installed
Z-Kidds-MacBook-Air:demo_app zkidd$
无论如何,这是我运行trace时的读数:
Z-Kidds-MacBook-Air:demo_app zkidd $ rake db:migrate --trace 耙子流产了! 你已经激活了rake 0.9.2.2,但你的Gemfile需要rake 0.8.7。使用bundle exec可以解决这个问题。 /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in
block in setup' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:17:in
setup' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler.rb:110:insetup' /Users/zkidd/rails_projects/demo_app/config/boot.rb:8:in
' /Users/zkidd/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire' /Users/zkidd/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require' /Users/zkidd/rails_projects/demo_app/config/application.rb:1:in<top (required)>' /Users/zkidd/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require' /Users/zkidd/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire' /Users/zkidd/rails_projects/demo_app/Rakefile:4:in
' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:inload' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in
load_rakefile' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:501:inraw_load_rakefile' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:82:in
块中的load_rakefile' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:81:in
load_rakefile' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:65:inblock in run' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
standard_exception_handling' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:inrun' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/bin/rake:33:in
' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/bin/rake:19:inload' /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/bin/rake:19:in
'
我还试图通过添加
来修改我的Gemfilegem "rake", "0.9.2.2"
但后来我明白了:
Z-Kidds-MacBook-Air:first_app zkidd $ rake db:migrate 警告:'require'rake / rdoctask''已弃用。请改用'require'rdoc / task'(在RDoc 2.4.2+中)。 at /Users/zkidd/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/rdoctask.rb 警告:不建议全局访问Rake DSL方法。请包括 ... Rake :: DSL成为使用Rake DSL方法的类和模块。 警告:DSL方法FirstApp :: Application#任务调用于/Users/zkidd/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.1/lib/rails/application.rb:214:在`initialize_tasks'中 Z-Kidds-MacBook-Air:first_app zkidd $
我正在跑步:
Rails 3.0.1
答案 0 :(得分:0)
在你的Gemfile中,将rake的版本设置为0.8.7到0.9.2.2:
gem "rake", "0.9.2.2"
然后运行您的更新:
bundle update
我实际上刚刚在我自己的一个项目中解决了这个问题。