Ruby on rails Can';t解密config/credentials.yml.enc

Ruby on rails Can';t解密config/credentials.yml.enc,ruby-on-rails,heroku,Ruby On Rails,Heroku,我正在使用Heroku与Rails 6和Postgres。我正试图使用heroku open启动应用程序,但构建失败,日志中显示了这一点: -----> Detecting rake tasks -----> Preparing app for Rails asset pipeline Running: rake assets:precompile DEPRECATION WARNING: Including LoggerSilence is deprec

我正在使用Heroku与Rails 6和Postgres。我正试图使用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
----->检测rake任务
----->为Rails资产管道准备应用程序
运行:rake资产:预编译
弃用警告:Include LoggerSilence已弃用,将在Rails 6.1中删除。请改用'ActiveSupport::LoggerSilence'(从at/tmp/build9537ba0878cb8933c15686548eb3ccb5/config/application.rb:7调用)
缺少用于解密文件的加密密钥。向您的团队索要主密钥,并将其写入/tmp/build_9537ba0878cb8933c15686548eb3ccb5/config/master.key,或将其放入ENV['RAILS\u master_key']。
!
!     预编译资产失败。
!
!     推送被拒绝,无法编译Ruby应用程序。
!     推送失败
我曾尝试运行这两个链接中提到的一些命令,但似乎都不起作用:


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

您需要将rails主键作为环境变量添加到heroku

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

    heroku config:set RAILS_MASTER_KEY=your-master-key
    

  • 如果您有此问题并且不使用Heroku,只需将credentials.yml.enc和master.key从工作的分支复制到有问题的分支