1

Deploying Rails App on Digital Ocean and when running cap production deploy:initial I get back

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

I thought that I've set it already:

development:
  secret_key_base: <%= ENV["132efa1cdc31b591fa97e11450182f7ece21c9409451ea74e65974a9fad9e1d27846895afe0ffc4ee09d0d87912532a8d64e9a465e3cdf4455dee4ff3830"] %>
test:
  secret_key_base: <%= ENV["1113232efa1cdc31b591fa97e11450182f7ece21c9409451ea74e65974a9fad9e1d27846895afe0ffc4ee09d0d87912532a8d64e9a465e3cdf4455dee4ff3830"] %>
production:
  secret_key_base: <%= ENV["11173232efa1cdc31b591fa97e11450182f7ece21c9409451ea74e65974a9fad9e1d27846895afe0ffc4ee09d0d87912532a8d64e9a465e3cdf4455dee4ff3830"] %>

I am using the digital ocean rails one click with ubuntu sever

Vasilisa
  • 4,604
  • 3
  • 20
  • 25
  • 2
    Possible duplicate of [Missing secret\_key\_base for 'production' environment,](https://stackoverflow.com/questions/51466887/missing-secret-key-base-for-production-environment) – Naing Lin Aung May 27 '19 at 04:11
  • @oreoluwa is right, you have your environment name & value flip-flopped in your code snippet you shared. – Jay Dorsey May 28 '19 at 03:40

1 Answers1

2

Usually your secret_key_base would be stored in an environment variable, however the secret key base isn't supposed to be the name of the env key. In your case, that's what I seem to observe.

development:
  secret_key_base: <%= ENV["132efa1cdc31b591fa97e11450182f7ece21c9409451ea74e65974a9fad9e1d27846895afe0ffc4ee09d0d87912532a8d64e9a465e3cdf4455dee4ff3830"] %>

test:
  secret_key_base: <%= ENV["1113232efa1cdc31b591fa97e11450182f7ece21c9409451ea74e65974a9fad9e1d27846895afe0ffc4ee09d0d87912532a8d64e9a465e3cdf4455dee4ff3830"] %>

production:
  secret_key_base: <%= ENV["11173232efa1cdc31b591fa97e11450182f7ece21c9409451ea74e65974a9fad9e1d27846895afe0ffc4ee09d0d87912532a8d64e9a465e3cdf4455dee4ff3830"] %>

So, here's what I'd propose, instead of setting your secret as the key of your env variable, you'd probably just want to do something like:

secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

Then, you'd want to set your environment variable in your digital ocean instance.

I've not used Capistrano before, but take a look at default_env in https://capistranorb.com/documentation/getting-started/configuration/ and Capistrano and environment variables

In your case, I figured you'd probably want to do something along the lines of

set :default_env, { 
  'SECRET_KEY_BASE' => '11173232efa1cdc31b591fa97e11450182f7ece21c9409451ea74e65974a9fad9e1d27846895afe0ffc4ee09d0d87912532a8d64e9a465e3cdf4455dee4ff3830'
}

Let me know if that helps

oreoluwa
  • 5,553
  • 2
  • 20
  • 27