gpt4 book ai didi

ruby-on-rails - 如何在 AWS 上生成缺失的 secret_key_base

转载 作者:行者123 更新时间:2023-12-02 00:06:20 27 4
gpt4 key购买 nike

我正在尝试使用 AWS EB CLI 在生产环境中启动我的 Rails 6.0.2.1、Ruby 2.6.5 应用程序,但是,我仍然遇到这个问题。为此,我尝试了 Google 搜索结果前两页中存在的所有解决方案,但均无济于事。

这些是我的错误日志:

ruby-2.0.0-p648
ruby-2.1.10
ruby-2.2.10
ruby-2.3.8
ruby-2.4.9
ruby-2.5.7
ruby-2.6.5
ruby-current ]]
+++ RUBIES+=("$dir"/*)
+++ for dir in '"$PREFIX/opt/rubies"' '"$HOME/.rubies"'
+++ [[ -d /.rubies ]]
+++ unset dir
+++ cat /etc/elasticbeanstalk/.ruby_version
++ chruby 2.6.5
++ case "$1" in
++ local dir match
++ for dir in '"${RUBIES[@]}"'
++ dir=/opt/rubies/ruby-1.9.3-p551
++ case "${dir##*/}" in
++ for dir in '"${RUBIES[@]}"'
++ dir=/opt/rubies/ruby-2.0.0-p648
++ case "${dir##*/}" in
++ for dir in '"${RUBIES[@]}"'
++ dir=/opt/rubies/ruby-2.1.10
++ case "${dir##*/}" in
++ for dir in '"${RUBIES[@]}"'
++ dir=/opt/rubies/ruby-2.2.10
++ case "${dir##*/}" in
++ for dir in '"${RUBIES[@]}"'
++ dir=/opt/rubies/ruby-2.3.8
++ case "${dir##*/}" in
++ for dir in '"${RUBIES[@]}"'
++ dir=/opt/rubies/ruby-2.4.9
++ case "${dir##*/}" in
++ for dir in '"${RUBIES[@]}"'
++ dir=/opt/rubies/ruby-2.5.7
++ case "${dir##*/}" in
++ for dir in '"${RUBIES[@]}"'
++ dir=/opt/rubies/ruby-2.6.5
++ case "${dir##*/}" in
++ match=/opt/rubies/ruby-2.6.5
++ for dir in '"${RUBIES[@]}"'
++ dir=/opt/rubies/ruby-current
++ case "${dir##*/}" in
++ [[ -z /opt/rubies/ruby-2.6.5 ]]
++ shift
++ chruby_use /opt/rubies/ruby-2.6.5 ''
++ [[ ! -x /opt/rubies/ruby-2.6.5/bin/ruby ]]
++ [[ -n '' ]]
++ export RUBY_ROOT=/opt/rubies/ruby-2.6.5
++ RUBY_ROOT=/opt/rubies/ruby-2.6.5
++ export RUBYOPT=
++ RUBYOPT=
++ export PATH=/opt/rubies/ruby-2.6.5/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
++ PATH=/opt/rubies/ruby-2.6.5/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
+++ /opt/rubies/ruby-2.6.5/bin/ruby -
++ eval 'export RUBY_ENGINE=ruby;
export RUBY_VERSION=2.6.5;
export GEM_ROOT="/opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0";'
+++ export RUBY_ENGINE=ruby
+++ RUBY_ENGINE=ruby
+++ export RUBY_VERSION=2.6.5
+++ RUBY_VERSION=2.6.5
+++ export GEM_ROOT=/opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0
+++ GEM_ROOT=/opt/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0
++ (( 0 != 0 ))
+ cd /var/app/ondeck
+ su -s /bin/bash -c 'bundle exec /opt/elasticbeanstalk/support/scripts/check-for-rake-task.rb assets:precompile' webapp
`/home/webapp` is not a directory.
Bundler will use `/tmp/bundler20200229-17441-1xumk3r17441' as your home directory temporarily.
+ '[' false == true ']'
+ su -s /bin/bash -c 'bundle exec rake assets:precompile' webapp
`/home/webapp` is not a directory.
Bundler will use `/tmp/bundler20200229-17445-s2fu1t17445' as your home directory temporarily.
rake aborted!
ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit`
/var/app/ondeck/config/environment.rb:5:in `<main>'
/opt/rubies/ruby-2.6.5/bin/bundle:23:in `load'
/opt/rubies/ruby-2.6.5/bin/bundle:23:in `<main>'
Tasks: TOP => environment
(See full trace by running task with --trace) (Executor::NonZeroExitStatus)


[2020-02-29T14:56:22.022Z] INFO [3700] - [Application update app-61df-200229_165115@2/AppDeployStage0/AppDeployPreHook/11_asset_compilation.sh] : Activity failed.
[2020-02-29T14:56:22.022Z] INFO [3700] - [Application update app-61df-200229_165115@2/AppDeployStage0/AppDeployPreHook] : Activity failed.
[2020-02-29T14:56:22.022Z] INFO [3700] - [Application update app-61df-200229_165115@2/AppDeployStage0] : Activity failed.
[2020-02-29T14:56:22.023Z] INFO [3700] - [Application update app-61df-200229_165115@2] : Completed activity. Result:
Application update - Command CMD-AppDeploy failed

我尝试设置 master.key,尝试通过 ENV 设置 secret_base_key,但均无效。

尽管使用 master.key 推送我的环境,但它永远不会存在于我的 SSH 环境中。

我也无法在我的 SSH 环境中运行 rails credentials:edit 并在本地运行它然后部署到生产中什么都不做,更改永远不会保留在 SSH 服务器,master 中。尽管所有设置都正确,但永远不会生成 key

我已经坚持了四天了,很好奇我是否应该转移到另一个平台,也许是 Heroku 或 Google?

最佳答案

您可以通过两种不同的方式设置SECRET_KEY_BASE 配置变量。

  1. 通过 Elastic Beanstalk 控制台环境变量设置此变量。在您的 EB 环境中,点击 Configuration -> Software,然后为 SECRET_KEY_BASE(全部大写)添加一个环境变量。

  2. 通过 Elastic Beanstalk 控制台环境变量配置设置 RAILS_MASTER_KEY 变量,并在您的加密凭证文件中设置 secret_key_base:

    • 在您的 EB 环境中,单击 Configuration -> Software,然后为 RAILS_MASTER_KEY(全部大写)添加一个环境变量。该值应该是您的 master.key 文件中的值。

    • 在本地运行 rails credentials:edit,并将以下行添加到您的文件中:

    secret_key_base: substitute-your-very-long-secret-key-here

    保存、关闭并提交文件。将这些更改部署到您的 Elastic Beanstalk 环境。

关于ruby-on-rails - 如何在 AWS 上生成缺失的 secret_key_base,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60466861/

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