Capistrano在铁路生产中未识别Secret_key_base。

发布于 2025-01-28 04:32:45 字数 1108 浏览 3 评论 0原文

我正在使用Capistrano用Ruby 3.1.1部署Rails 7.0.2应用程序,当我运行CAP Production Deploy时,然后Capistrano运行时:

deploy:assets:precompile
$HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile

我会收到以下错误:

ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit`

Deviploy.rb:

# config valid for current version and patch releases of Capistrano
lock '~> 3.17.0'

set :application, 'app'
set :repo_url, '[email protected]:foo/app.git'

# Deploy to the user's home directory
set :deploy_to, "/#{fetch :application}"

append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'

# Only keep the last 5 re

问题。是我已经在Productions加密的凭据文件中定义了Secret_key_base,因此我不应该遇到此错误。我还尝试将secret_key_base放置为.rbenv-vars文件,但仍然有相同的错误。如何在带有Rails和Capistrano的生产环境中正确使用Secret_key_base?再次感谢!

I'm using Capistrano to deploy my Rails 7.0.2 app with Ruby 3.1.1, when I run cap production deploy and then when Capistrano runs:

deploy:assets:precompile
$HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile

I receive the following error :

ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit`

deploy.rb:

# config valid for current version and patch releases of Capistrano
lock '~> 3.17.0'

set :application, 'app'
set :repo_url, '[email protected]:foo/app.git'

# Deploy to the user's home directory
set :deploy_to, "/#{fetch :application}"

append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'

# Only keep the last 5 re

The problem is that I already have the secret_key_base defined in my productions encrypted credentials file so I should not be getting this error. I also tried putting the secret_key_base as a .rbenv-vars file and still got the same error. How do I properly use a secret_key_base in a production environment with Rails and Capistrano? Thanks again!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

虫児飞 2025-02-04 04:32:45

您可以尝试将deploy.rb文件添加到deploy.rb文件:

append:linked_files,'config/contractials/production.key',

并复制production.key(负责解密生产凭证的一个)到服务器中的共享文件夹,类似/var/www/{proyect_name}/shared/shared/config/config/config/credentials/production.key您可以将production.yml.enc留在您的github中。

并检查您是否已使用编辑器中的Secret_key_base设置Secret_key_base = Nano Rails凭据:编辑-e生产

Can you try adding to the deploy.rb file:

append :linked_files, 'config/credentials/production.key',

And copy the production.key (the one that is in charge of decrypting the production credentials) to the shared folder in your server, something like /var/www/{proyect_name}/shared/config/credentials/production.key you can leave the production.yml.enc in your GitHub.

And check that you have set the secret_key_base in your production secret keys with EDITOR=nano rails credentials:edit -e production

一袭水袖舞倾城 2025-02-04 04:32:45

将以下内容添加到config/Environments/code

config.require_master_key = true

运行editor = editor = vi rails凭据:edit -environment = production
将生成的生成键保存到您的服务器 @ app/config/config/recortentials/production.key

更改set:deverloy_to,“/#{fetch:application}” to set:dever_to,“〜/#{fetch:application}”

Added the following to config/environments/production:

config.require_master_key = true

run EDITOR=vi rails credentials:edit --environment=production
Save the production key generated to your server @ app/config/credentials/production.key

Changed set :deploy_to, "/#{fetch :application}" to set :deploy_to, "~/#{fetch :application}"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文