Alex Nikolsky
Alex Nikolsky

Reputation: 2179

Missing `secret_token` and `secret_key_base` for 'development' environment, set these values in `config/secrets.yml`

When I try to run rails server command I get the error

enter image description here

How to solve it?

My config/environments/development.rb

Rails.application.configure do

  config.secret_key_base = ENV["SECRET_KEY_BASE"]

  #Some stuff 

end

And I don't have the secret.yml file in my folder.

enter image description here

Upvotes: 18

Views: 26733

Answers (5)

Ishmael MIRZAEE
Ishmael MIRZAEE

Reputation: 1220

My solution to the problem is creating a new project then copy the 'secrets.yml` from the newly generated app into the old project.

rails new TmpApp

cd TmpApp/config

cp secrets.yml /Path/to/old/project/config/

Upvotes: 1

The following solution helped me:

Create a secrets.yml file in your config directory.

In your terminal, type the following command: rake secret. This will generate a secret for you to include in your secrets.yml file.

Add the following snippet of code to your config/secrets.yml file:

development: secret_key_base: PASTE_YOUR_GENERATED_SECRET_HERE

Upvotes: 1

Aleksandar Pavić
Aleksandar Pavić

Reputation: 3440

You skipped one installation step.

For Redmine 2 and 3 versions, type:

RAILS_ENV=production bundle exec rake generate_secret_token

Upvotes: 2

Douglas G. Allen
Douglas G. Allen

Reputation: 2261

I encountered this same issue with Redmine. There is a Rake task to generate it. It does not need to go into a Yaml file. It goes into a secret_tocken.rb file in the initializers folder.

Upvotes: 0

ddavison
ddavison

Reputation: 29082

Then create one:

config/secrets.yml

# be sure to restart your server when you modify this file...
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
development:
  secret_key_base:  asdflkjasdlfkjasldfkj

test:
  secret_key_base:  asdflkhasldfhlhaskdlflakhsdf

production:
  secret_key_base: 523lk5h2lkjlj6nlk4n6lk4

obviously don't use those keys above ^ just mash on your keyboard, or use rake secret to generate one :)

Upvotes: 39

Related Questions