【问题标题】:Heroku rake db:structure:load with cleardb can't find 'mysql'Heroku rake db:structure:load with cleardb 找不到 'mysql'
【发布时间】:2017-06-07 22:41:50
【问题描述】:

我正在尝试在 heroku dyno 上安装 Sharetribe 的实例。我正试图创建数据库。我首先尝试了 rake db:migrate,它适用于大多数迁移,但其中一个失败了。

有人建议我使用 rake db:structure:load,所以我尝试了,但 Heroku 收到一个错误,提示需要将 mysql 添加到 PATH 变量中。为什么会这样,我该如何解决?我不知道为什么它会发生在 db:schema:load 和 db:structure:load 而不是 db:migrate。

带有错误消息的完整堆栈跟踪是:

rake aborted!
failed to execute:
mysqlPlease check the output above for any errors and make sure that `mysql` is installed in your PATH and has proper permissions.

/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/mysql_database_tasks.rb:148:in `run_cmd'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/mysql_database_tasks.rb:72:in `structure_load'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:189:in `structure_load'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:222:in `load_schema_for'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:236:in `block in load_schema_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:276:in `block in each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:235:in `load_schema_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:293:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `kernel_load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in `exec'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:34:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:26:in `<top (required)>'
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'
Tasks: TOP => db:structure:load
(See full trace by running task with --trace)

谢谢!

【问题讨论】:

    标签: mysql ruby-on-rails heroku cleardb sharetribe


    【解决方案1】:

    如果您需要运行heroku run bundle exec rake db:structure:load,则需要安装mysql 客户端。 要安装其他软件包,您需要添加 Buildpacks(官方或社区)。

    对于mysql我成功使用https://github.com/din-co/heroku-buildpack-mysql

    heroku buildpacks:add --index 1 https://github.com/din-co/heroku-buildpack-mysql
    git commit --amend --allow-empty --no-edit
    git push heroku -f
    

    【讨论】:

    • 无法推送代码heroku,出现以下错误“无法创建/tmp/build_5263549fb7972f391b94a0afd55680d0/.profile.d/mysql.sh:目录不存在”
    【解决方案2】:

    Heroku 不支持mysql,您需要在生产块的gemfile 中使用pg gem。 请阅读Getting Started with Rails 5.x on Heroku

    【讨论】:

    • 是的,我知道 Heroku 本身并不托管 MySQL 数据库。我正在尝试通过 Heroku ClearDB 插件连接到由 ClearDB 托管的云数据库。这是绝对可能的,人们这样做,但我不确定为什么在这种情况下会出现问题。
    • 所以我假设您已经完成了这里的所有步骤devcenter.heroku.com/articles/cleardb 是吗?您是否删除/删除了 pg gem 和/或插件?
    • 我做到了,但 heroku 从未将 postgres 插件显示为存在于我的测功机上。
    猜你喜欢
    • 1970-01-01
    • 2017-06-22
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多