【问题标题】:heroku rake:db command error undefined method task' forheroku rake:db 命令错误未定义的方法任务'
【发布时间】:2012-12-07 08:34:04
【问题描述】:

我尝试 heroku 运行 bundle exec rake db:create --trace

有错误

    rake aborted!
    undefined method task' for #<CertApp::Application:0x00000002ad5488>
    /app/vendor/bundle/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:215:i
    ninitialize_tasks'
    /app/vendor/bundle/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:139:i
    n load_tasks'
    /app/vendor/bundle/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:in
    method_missing'
    /app/Rakefile:8:in <top (required)>'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/rake_module.rb:25:inlo
    ad'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/rake_module.rb:25:in lo
    ad_rakefile'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:581:inr
    aw_load_rakefile'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:87:in bl
    ock in load_rakefile'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:158:ins
    tandard_exception_handling'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:86:in lo
    ad_rakefile'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:70:inbl
    ock in run'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:158:in s
    tandard_exception_handling'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:68:inru
    n'
    /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/bin/rake:37:in `'

    /app/vendor/bundle/ruby/1.9.1/bin/rake:19:in load'
    /app/vendor/bundle/ruby/1.9.1/bin/rake:19:in'

in gemfile 

gem 'rake', '0.8.7'

我该怎么办?

【问题讨论】:

    标签: heroku


    【解决方案1】:

    您不需要在 Heroku 上创建数据库,它已经存在。作为部署过程的一部分,他们为您编写 database.yml。

    【讨论】:

    • 好的,但是我的应用程序没有工作。和命令 heroku rake:db migrate 引发一些错误。
    【解决方案2】:

    答题2:

    我知道你的 gemfile 是 0.8.7,但 /app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.2/lib/rake/rake_module.rb:25:inload' 行来自你的机器,而不是 Heroku。这意味着你在某处有 rake 10.0.2。

    我们应该能够通过运行 heroku bundle exec rake db:migrate 来避免使用 10.0.2,这应该会强制使用 0.8.7,但我宁愿完全卸载 10.0.2,这样你就可以运行 heroku rake db:migrate

    所以,让我们确保您只使用 rake 0.8.7。 按顺序尝试这些操作:

    1. 从您的 gemfile 中删除 rake 行。保存。关闭它。
    2. 卸载 rake:gem uninstall rake(或 gem uninstall rake -v 10.0.2,如果第一个不起作用)
    3. 运行包安装和包更新
    4. 重新安装 rake 0.8.7:将 gem 'rake', '0.8.7' 重新添加到您的 gemfile。
    5. 再次运行捆绑安装
    6. 运行heroku bundle exec rake db:migrate

    请多多指教,因为我在这方面的知识已达到极限。

    【讨论】:

    • @Sashe,你在这方面有没有成功过?
    • 对不起,我没有足够的时间尝试。我一试,马上写结果
    猜你喜欢
    • 1970-01-01
    • 2012-01-13
    • 2015-02-22
    • 1970-01-01
    • 2011-09-04
    • 2013-03-03
    • 2011-06-11
    • 1970-01-01
    • 2021-07-06
    相关资源
    最近更新 更多