Don't load app environment when editing credentials #34789
While evaluating multi-environment credentials, I came across a problem trying to create a new environment for my app.
Once you have created your first environment (e.g.
# config/initializers/sidekiq.rb Sidekiq::Web.set :session_secret, Rails.application.credentials.secret_key_base!
That works fine when running
If you now decide to create a
A great many gems that access 3rd party APIs use an initialiser for configuring credentials so the above situation is quite likely to occur.
I worked around the issue by creating a new empty Rails app, running
This PR attempts to fix the issue by not loading the application environment for
I've added a test but I am not sure that it is correct (or sufficient) as I struggled to fully understand the railties test harness. Happy to try another way to test this.
This avoids missing key exceptions caused by code that tries to read the credentials before they have been added to the encrypted file, for example when editing the credentials for a new environment.