“在“生产"环境中缺少"secret_key_base"" Heroku上的错误 [英] "Missing `secret_key_base` for 'production' environment" error on Heroku

查看:129
本文介绍了“在“生产"环境中缺少"secret_key_base"" Heroku上的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一次在Heroku上部署我的应用程序时收到错误消息发生未处理的低级错误",并且heroku logs显示:

I received the error "An unhandled lowlevel error occurred" when deploying my app for the first time on Heroku, and heroku logs shows:

在生产"环境中缺少secret_key_base,请设置此值 在config/secrets.yml

Missing secret_key_base for 'production' environment, set this value in config/secrets.yml

1)默认secrets.yml指定用于生产的secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

1) The default secrets.yml specifies secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> for production

2)我使用rails secret生成了一个秘密,然后通过heroku config:set SECRET_KEY_BASE='(the key)'

2) I generated a secret using rails secret, then added this to my app's Heroku config via heroku config:set SECRET_KEY_BASE='(the key)'

3)heroku config显示为SECRET_KEY_BASE

4)也许最重要的是,根据有关该错误的较旧问题,.gitignore 包括secrets.yml-这是为Rails 5应用程序生成的默认.gitignore.因此,secrets.yml应该已经与我的应用程序一起部署,该应用程序指定通过生产环境中的环境变量来加载机密.

4) Perhaps most importantly, based on older questions regarding this error, .gitignore does not include secrets.yml--it's the default .gitignore generated for a Rails 5 app. Therefore, secrets.yml should have been deployed with my app, which specifies that the secret be loaded via an environment variable in the production environment.

5)我还运行了heroku ps:restart,以防应用程序需要一些额外的帮助来使环境变量设置生效

5) I've also run heroku ps:restart, in case the app needed some extra help for the environment variable setting to take effect

我阅读了较早的文章,但过去的答案似乎是确保secrets.yml未包含在.gitignore中,但是如上所述,这不适用于默认的Rails 5 .gitignore.

I read older posts, but the past answer seemed to be ensuring secrets.yml was not included in .gitignore, but as mentioned, this does not apply to the default Rails 5 .gitignore.

我还能尝试什么?谢谢.

What else can I try? Thx.

当我在命令行中设置config值时,我还会收到Heroku消息:

When I set the config value at the command line, I also receive the Heroku message:

设置SECRET_KEY_BASE并重新启动(应用程序).​​..完成

Setting SECRET_KEY_BASE and restarting (the app)... done

推荐答案

好的,我知道发生了什么.运行heroku run bash并检查部署了哪些文件已经很有意义.

Okay, I see what happened. Running heroku run bash and checking which files were deployed has been enlightening.

确实,secrets.yml不在我的本地存储库的.gitignore文件中,但是看来某人-可能是恶意黑客,可能是gremlins-添加了secrets.yml到我的全局.gitignore(.gitignore_global),因此实际上该文件不是 被推送到Heroku.

It is true that secrets.yml was not in the .gitignore file for my local repo, but it seems that someone--possibly malicious hackers, possibly gremlins--had added secrets.yml to my global .gitignore (.gitignore_global), and so this file was in fact not being pushed to Heroku.

我已经从全局.gitignore中删除了秘密文件,将开发和测试环境的秘密密钥卸载到dotenv进行管理,并且可以成功运行我部署的应用程序.

I've removed the secrets file from my global .gitignore, offloaded the dev and test environment secret keys to dotenv for management, and can run my deployed app successfully.

我曾考虑删除此问题,但如果其他人遇到此问题,甚至在诊断Heroku应用程序问题时使用heroku run bash的类似问题,都会保留该问题.

I thought about deleting the question, but will leave it in case others run into this problem, or even a similar one where using heroku run bash may be helpful when diagnosing issues with apps on Heroku.

这篇关于“在“生产"环境中缺少"secret_key_base"" Heroku上的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆