whenever icon indicating copy to clipboard operation
whenever copied to clipboard

Rails 5.2.0 requires RAILS_MASTER_KEY

Open morgoth opened this issue 7 years ago • 3 comments

Rails 5.2.0 introduced encrypted credentials http://weblog.rubyonrails.org/2018/3/20/Rails-5-2-RC2/

If one wants to use it, then it has to set RAILS_MASTER_KEY environment variable (there is also a way with static file, but I guess env variable is a recommended one).

The problem with cron and whenever is that by default this env is not set, thus launching rails app will fail with error ActiveSupport::EncryptedFile::MissingKeyError: Missing encryption key to decrypt file with. Ask your team for your master key and write it to config/master.key or put it in the ENV['RAILS_MASTER_KEY'].

To fix it, it's enough to write in schedule.rb: env :RAILS_MASTER_KEY, ENV["RAILS_MASTER_KEY"]

I'm wondering if whenever should do it out of the box, as it is already having some Rails related code, I guess it would go here https://github.com/javan/whenever/blob/master/lib/whenever/setup.rb#L7

If not, maybe some addition to Readme would be good so people are aware?

morgoth avatar Apr 16 '18 11:04 morgoth

Your suggestion would result in the master key being written to the crontab, which I don’t think is desirable. The default job template launches a login shell. Maybe it is better to suggest placing the master key either in the suggested file or in the user’s shell environment.

benlangfeld avatar Apr 16 '18 11:04 benlangfeld

This has tripped me up in docker, when adapting your user profile ~is too much work~ exceeds my capabilites 😉

I think it would be worth noting this exactly in the README, or in the Wiki's troubleshooting section!

julianrubisch avatar Sep 14 '20 11:09 julianrubisch

This is still a problem for me, does anyone has an elegant solution?

rikas avatar Mar 23 '22 11:03 rikas