a month ago
Hi! I'm using Rails 8.2's new Rails.app.creds feature and have set both the master key (via RAILS_MASTER_KEY) and the configs with environment variables (e.g. DATABASE__NAME for [:database, :name].
However, when I try to deploy, I get this error:
KeyError: Missing key: [:database, :name] (KeyError)
/usr/local/bundle/ruby/3.4.0/bundler/gems/rails-90ccb4501a2e/activesupport/lib/active_support/combined_configuration.rb:28:in 'ActiveSupport::CombinedConfiguration#require'
/rails/config/database.yml:22:in '<main>'How can I fix this?
3 Replies
a month ago
The double underscore syntax (DATABASE__NAME) for nested credentials is a Rails 8.2-specific convention that Rails interprets on its end, not a Railway feature. For this to work, the environment variable must be set in your service's Variables tab. Verify that DATABASE__NAME is actually present there with the correct value. If you're referencing a Railway Postgres database, you might set it to ${{Postgres.PGDATABASE}} or the literal database name. Also confirm RAILS_MASTER_KEY matches your local config/master.key exactly. If both variables are set correctly and you're still seeing the error, the issue may be with how Rails 8.2's CombinedConfiguration loads ENV vars during the build phase - you might need to ensure these variables are available at build time, not just runtime.
Status changed to Awaiting User Response Railway • about 1 month ago
angelo-railway
The double underscore syntax (DATABASE__NAME) for nested credentials is a Rails 8.2-specific convention that Rails interprets on its end, not a Railway feature. For this to work, the environment variable must be set in your service's Variables tab. Verify that DATABASE__NAME is actually present there with the correct value. If you're referencing a Railway Postgres database, you might set it to ${{Postgres.PGDATABASE}} or the literal database name. Also confirm RAILS_MASTER_KEY matches your local config/master.key exactly. If both variables are set correctly and you're still seeing the error, the issue may be with how Rails 8.2's CombinedConfiguration loads ENV vars during the build phase - you might need to ensure these variables are available at build time, not just runtime.
a month ago
The variable is set and RAILS_MASTER_KEY is the same as the config/master.key!
Status changed to Awaiting Railway Response Railway • about 1 month ago
a month ago
What happens when you run it locally with the CLI with railway run?
Status changed to Awaiting User Response Railway • about 1 month ago
a month ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • about 1 month ago