0

I've tried all night to deploy to Heroku, but I keep getting the same error:

remote: -----> Preparing app for Rails asset >pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: Devise.secret_key was not set. Please add the following to your Devise initializer:
remote: config.secret_key = 'secret token string'
remote: Please ensure you restarted your application after installing Devise or setting the key.

...

remote: ! Precompiling assets failed.
remote: !
remote:
remote: ! Push rejected, failed to compile Ruby app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to viral-blocitoff.
remote:
To https://git.heroku.com/viral-blocitoff.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/viral-blocitoff.git'

I also ran the following to set my environment variable for heroku:

    figaro heroku:set -e production

This read all my fixed values, including SENDGRID and DEVISE_SECRET_KEY

Here is my application.yml file (minus the fixed values):

    SENDGRID_PASSWORD: ********
    SENDGRID_USERNAME: @heroku.com

    production:
      SECRET_KEY_BASE: secret token
      DEVISE_SECRET_KEY: secret token

This is what I have in my devise.rb file:

    config.secret_key = ENV['DEVISE_SECRET_KEY']

I looked at other proposed solutions on this site, but I made Devise work on another app less than two months ago without going through such tasks. Is there something I am missing?

Vman
  • 31
  • 7
  • https://stackoverflow.com/questions/18080910/devise-secret-key-was-not-set#answer-22584303 – Pardeep Dhingra Jun 07 '15 at 05:45
  • you must have added `application.yml` in `.gitignore` so, make sure you have set the environment variables either manually via GUI inside `settings` or using `Figaro` and you have no alignment issues in YAML – Shiva Jun 07 '15 at 13:34
  • The app works in development when running on Rails server--no hang ups at all, with authentication, emails, or other things. – Vman Jun 07 '15 at 14:06
  • @CbaBhusal I did use figaro to set my environment variables, and I confirmed with the command "heroku config" The variables showed the same fixed values I have in application.yml. I'm trying to think of what sort of alignment issues there could be? – Vman Jun 07 '15 at 14:09
  • @CbaBhusal yes, I do have application.yml in .gitignore. however I pushed secrets.yml to my remote on github, but it does not have the actual values. – Vman Jun 07 '15 at 14:10
  • try once running you app in production mode in local `rails s -e production` – Shiva Jun 07 '15 at 14:36
  • @CbaBhusal tried to run it in production locally, got the welcome page, but could not sign in. Error message: something went wrong, check logs. But was able to run app in development locally, with no functionality problems. scratching my head? – Vman Jun 07 '15 at 17:55
  • ok then try pre-compiling the assets in local and push – Shiva Jun 08 '15 at 04:02

2 Answers2

0

Got it to deploy. I unset my heroku env variables, then reset them. I also used one token (via ENV variable) for both development and production secret_key_base Pushed remote master to Heroku, it compiled and launched. Then migrated the database too to Heroku. All is well.

Vman
  • 31
  • 7
0

My application was reporting the same error, however, the issue results from a combination of using the Figaro gem and rigid systemAdmin. Upon implementing the Figaro gem, creating a secrets.yml file for assigning authentication tokens, then appropriately storing it within .gitignore, a conflict can occur when attempting to deploy to heroku because the .gitignore prevents pushing the secrets.yml file credentials necessary for deployment.

Specifically, I used the following gem and procedure to resolve the conflict.

  1. gem 'heroku_secrets', github: 'alexpeattie/heroku_secrets'
  2. bundle install
  3. git push heroku master --force

The abovementioned solution is explained further in a related StackOverflow post: How do you manage secret keys and heroku with Ruby on Rails 4.1.0beta1?

Moreover, I've encountered multiple issues using Figaro in Rails 4.1; I've detailed problems associated with administration of secrets.yml at the following Gist.

Hopefully this helps-thanks!

Community
  • 1
  • 1