Capistrano在铁路生产中未识别Secret_key_base。
我正在使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试将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
将以下内容添加到
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}”
toset: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}"
toset :deploy_to, "~/#{fetch :application}"