0

I'm am working as a part of a team for a school project. We are using Ruby 2.6.5 and Rails 6.0.2.1. I have pulled the master branch from GitHub, but when I try to run the application I get this error:

ArgumentError: Missing secret_key_base for 'production' environment

I have looked online and found that the old solution was to change the config/secrets.yml file, but rails 6 no longer has that file, and instead has an encoded credentials.yml.enc file that has the same functionality. How do I fix this issue?

nag1298
  • 3
  • 1
  • Does this answer your question? [Missing \`secret\_key\_base\` for 'production' environment on Ubuntu 18.04 server (Rails 6.0), multiple topics tried](https://stackoverflow.com/questions/57290160/missing-secret-key-base-for-production-environment-on-ubuntu-18-04-server-r) – Yury Matusevich Mar 12 '20 at 12:03
  • Do you have a `master.key` in the `config` folder? – Rafayet Monon Mar 12 '20 at 18:21

2 Answers2

0

You can try changing the config.require_master_key = true #in config/environments/production.rb

You can go to this link to check this in detail:- https://blog.engineyard.com/rails-encrypted-credentials-on-rails-5.2

I hope this will work for you.

Community
  • 1
  • 1
0

Rails > 5.2 introduced a new feature for securing credentials. For this rails uses a master.key in config folder which is usually added to .gitignore so that it stays secure and doesn't get pushed to git.

This master.key is used to encrypt or decrypt content from the credentials.yml.enc file which you found.

If you are working on a team then the project creator will have to share this master.key file to you personally or you have to create a new credentials.yml.enc. You can do it using the below command -

EDITOR=vim rails credentials:edit

This will create a new master.key and credentials.yml.enc in your machine but the changes made by your teammates in the credentials.yml.enc will be lost. To avoid that hassle just get the master.key from your teammate and put it in the config. folder.

Rafayet Monon
  • 1,019
  • 8
  • 16