Missing `secret_key_base` for Production with Rails

Trying to deploy

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

Now there is A secret_key_base in the file. So I don’t know what it is complaining about really. Any ideas? Been searching the web but nothing seems to work.

The bin/rails credentials:edit is borked when using Atom as it won’t open the Atom editor ( seems to be a common but unfixed problem ) but this is an aside.

To answer my own question. You need to go to dashboard, environment and set an environment variable SECRET_KEY_BASE with your secret_key_base value.

Easy once you know.

1 Like

Hi Colin,

Thanks for updating your post with your solution to help other community members.

It seems that in Rails environments other than development/test, it will check through various locations for the secret_key_base, starting with the env var:

...ENV["SECRET_KEY_BASE"] || credentials.secret_key_base || secrets.secret_key_base...

source

From that, it seems the credentials method should’ve also worked, however, I guess that possibly depends on how your credentials file(s) and master key are set up.

Kind regards

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.