We've moved discussions to Discord

Heroku Deployment Fails at start-up

Donavin Northrup
2019-11-07T18:49:50.363700+00:00 app[web.1]: 	from bin/rails:9:in `<main>'2019-11-07T18:49:50.424935+00:00 heroku[web.1]: Process exited with status 12019-11-07T18:49:56.376588+00:00 app[web.1]: => Booting Puma2019-11-07T18:49:56.376620+00:00 app[web.1]: => Rails 6.0.0 application starting in production 2019-11-07T18:49:56.376623+00:00 app[web.1]: => Run `rails server --help` for more startup options2019-11-07T18:49:57.545612+00:00 app[web.1]: Exiting2019-11-07T18:49:57.546322+00:00 app[web.1]: /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/base64.rb:59:in `decode64': undefined method `unpack1' for nil:NilClass (NoMethodError)2019-11-07T18:49:57.546328+00:00 app[web.1]: 	from /app/app/models/user/connected_account.rb:37:in `<class:ConnectedAccount>'2019-11-07T18:49:57.546332+00:00 app[web.1]: 	from /app/app/models/user/connected_account.rb:31:in `<main>'2019-11-07T18:49:57.546334+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'2019-11-07T18:49:57.546353+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'2019-11-07T18:49:57.546355+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'2019-11-07T18:49:57.546357+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'2019-11-07T18:49:57.546359+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'

It continues on like this for awhile, but it's a lot of similar errors around ruby.rb, kernel_ruby.rb (Or something similar). It builds successfully locally, but as soon as I push it to Heroku this happens.

heroku run rake db:migrate works (It seems) and the DBs are generated. Redis is installed, and I added in the webpack it said too. Anything else I might be missing?
Chris Oliver
Hey  Donavin Northrup !

Looks like you're missing your Rails credentials for Heroku. When you deploy to Heroku, you'll want to make sure that you have set the RAILS_MASTER_KEY in the env vars so it can decrypt the credentials for production.
Donavin Northrup
Hey  Chris Oliver ,

Thanks for replying; Is it safe to assume this should be the `test.key` under `config/credentials`? If so, I have that currently.

If it matters, for the first few lines it is:

2019-11-08T04:04:29.933218+00:00 app[web.1]: => Booting Puma2019-11-08T04:04:29.933239+00:00 app[web.1]: => Rails 6.0.0 application starting in production 2019-11-08T04:04:29.933241+00:00 app[web.1]: => Run `rails server --help` for more startup options2019-11-08T04:04:31.758795+00:00 app[web.1]: Exiting2019-11-08T04:04:31.759104+00:00 app[web.1]: /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/base64.rb:59:in `decode64': undefined method `unpack1' for nil:NilClass (NoMethodError)2019-11-08T04:04:31.759110+00:00 app[web.1]: 	from /app/app/models/user/connected_account.rb:37:in `<class:ConnectedAccount>'2019-11-08T04:04:31.759116+00:00 app[web.1]: 	from /app/app/models/user/connected_account.rb:31:in `<main>'2019-11-08T04:04:31.759118+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'2019-11-08T04:04:31.759123+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
Chris Oliver
Sort of. You will have to create credentials for each environment you want to run. If you're using RAILS_ENV=production on Heroku (which you normally will), then you need to run "rails credentials:edit --environment=production" and add your keys. That will create config/credentials/production.key and that's what you'd want to put in Heroku as RAILS_MASTER_KEY.

More details on all that:
https://jumpstartrails.com/jumpstart/docs/credentials

And:
https://blog.bigbinary.com/2019/07/03/rails-6-adds-support-for-multi-environment-credentials.html
Donavin Northrup
Thanks for the links, so this is the reference I expected - So I modified Heroku to Test environment, and included the `test.key` within it, however the failures are still similar.

They kick off slightly different (Blaming letter_opener now) but still references some `kernel.rb` file.

2019-11-08T12:49:49.741465+00:00 app[web.1]: => Booting Puma2019-11-08T12:49:49.741497+00:00 app[web.1]: => Rails 6.0.0 application starting in test 2019-11-08T12:49:49.741504+00:00 app[web.1]: => Run `rails server --help` for more startup options2019-11-08T12:49:50.513460+00:00 app[web.1]: Exiting2019-11-08T12:49:50.516869+00:00 app[web.1]: /app/config/routes.rb:7:in `block in <main>': uninitialized constant LetterOpenerWeb (NameError)2019-11-08T12:49:50.516899+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.0/lib/action_dispatch/routing/route_set.rb:429:in `instance_exec'2019-11-08T12:49:50.516929+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.0/lib/action_dispatch/routing/route_set.rb:429:in `eval_block'2019-11-08T12:49:50.516955+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.0/lib/action_dispatch/routing/route_set.rb:411:in `draw'2019-11-08T12:49:50.516982+00:00 app[web.1]: 	from /app/config/routes.rb:2:in `<main>'2019-11-08T12:49:50.517008+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'2019-11-08T12:49:50.517034+00:00 app[web.1]: 	from /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
Chris Oliver
You should try to set the environment to development or production with the relevant credentials file/key. I'm not sure that you want to run test on Heroku. 

The LetterOpener route is included in the test environment, but the gem isn't so I'll have to fix that so it's consistent.
Willard Moore
I ran into the same issue because I wasn't familiar with the credentials change with rails 5.2 and up. 
Chris Oliver
Just updated the docs to include a video and detailed Heroku instructions: https://jumpstartrails.com/jumpstart/docs/deploying
Jeff Helman
I got the same basic errors (deploying a fresh instance of the OOTB Jumpstart Pro template, freshly pushed from known-good on local system). As shown below, I did configure the (production) credentials key (and set RAILS_MASTER_KEY) in Heroku:

Screen Shot 2019-11-20 at 8.27.11 PM.png 444 KB


... so I looked at the Build Log in Heroku:
Screen Shot 2019-11-20 at 8.29.29 PM.png 437 KB


I wasn't sure if that "Detecting rails configuration failed" message was noise or real, but it smelled very relevant.  I set the HEROKU_DEBUG_RAILS_RUNNER flag as described, then poked around some more (several StackOverflow searches) ... and then:
  • I realized I had not committed the config/credentials/production.yml.enc file to git after editing, so it did not get to Heroku when I did my get push (to Heroku).

I hope this helps others.
Chris Oliver
I'm going to try and figure out if I can have Jumpstart auto-generate credentials files for each environment and add them to git for you automatically. That should help save some trouble for everyone. 👍
Willard Moore
That tripped me up when I saw it too. I hadn’t worked with credential files like that yet. Just a learning curve. Btw  Chris Oliver , I emailed you about a bug I found. 
Chris Oliver
I just pushed up a commit that automatically generates a credentials file for each environment when you save the Jumpstart config. 👍
Jeff Helman
Wow, Chris, that is just awesome! Thanks!
Notifications
You’re not receiving notifications from this thread.