无法解密config / credentials.yml.enc

时间:2019-09-28 17:56:31

标签: ruby-on-rails heroku

我在Rails 6和Postgres中使用Heroku。我正在尝试使用heroku open启动应用程序,但是构建失败,并且在日志中显示:

-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       DEPRECATION WARNING: Including LoggerSilence is deprecated and will be removed in Rails 6.1. Please use `ActiveSupport::LoggerSilence` instead (called from <top (required)> at /tmp/build_9537ba0878cb8933c15686548eb3ccb5/config/application.rb:7)
       Missing encryption key to decrypt file with. Ask your team for your master key and write it to /tmp/build_9537ba0878cb8933c15686548eb3ccb5/config/master.key or put it in the ENV['RAILS_MASTER_KEY'].
 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

我试图运行这两个链接中提到的某些命令,但似乎没有一个起作用:

https://github.com/rails/rails/issues/32947

Ask your team for your master key and put it in ENV["RAILS_MASTER_KEY"] on heroku deploy

我还想知道这些工作流程是否特定于环境。

2 个答案:

答案 0 :(得分:2)

您需要将Rails主密钥作为环境变量添加到heroku

  1. 将主密钥复制到计算机中的config/master.key文件中
  2. 将主密钥添加为heroku作为环境变量

    heroku config:set RAILS_MASTER_KEY=your-master-key
    

答案 1 :(得分:0)

如果您遇到此问题并且不使用Heroku,只需将可工作的分支中的certificate.yml.enc和master.key复制到有问题的分支中。