gpt4 book ai didi

ruby-on-rails - heroku run rake db :migrate . .. rake 中止!未找到 Rakefile

转载 作者:行者123 更新时间:2023-12-01 03:49:18 25 4
gpt4 key购买 nike

当我跑 heroku run rake db:migrate ,我收到以下错误:

$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.8507
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/usr/local/lib/ruby/1.9.1/rake.rb:2367:in `raw_load_rakefile'
/usr/local/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/local/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/local/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/local/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/local/bin/rake:31:in `<main>'

其他用户发布了相同的错误,但在他们的情况下,他们实际上没有 Rakefile,一旦他们创建了一个 Rakefile,它就会为他们工作,或者他们在错误的目录中。我的应用程序确实有一个 Rakefile,在正确的目录中,其中包含所有正确的文本,而且我在我的应用程序的根目录中。

这是我的 Rakefile 的样子:
    # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks

这就是“heroku run cat Rakefile”所做的:
    $ heroku run cat Rakefile
Running `cat Rakefile` attached to terminal... up, run.9132
cat: Rakefile: No such file or directory

最佳答案

每当你在 Heroku 上挣扎时,你应该检查你的日志:

heroku logs
扫描任何您可以使用谷歌搜索的错误和/或获取问题提示。
如果您正在使用 git,您可以使用以下命令快速搜索错误:
git grep "whatever you want to search for"
然后,您将知道在哪里可以找到该文件,因此您可以尝试使用以下命令验证 rakefile 是否确实存在:
git grep rakefile
有时,重新开始并重置数据库并重新加载当前模式更容易:
rake db:reset db:migrate all
这将破坏您的数据库,然后创建它,然后迁移您当前的架构:
rake db:drop db:create db:migrate 
如果你想重置heroku db
要删除数据库,如果您使用 SHARED_DATABASE_URL:
heroku pg:reset DATABASE
要重新创建没有任何内容的数据库:
heroku run rake db:migrate
要使用您的种子数据填充数据库:
heroku run rake db:seed

关于ruby-on-rails - heroku run rake db :migrate . .. rake 中止!未找到 Rakefile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24320837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com