CLI: `railway shell` has ENV variables, but not accessible in Rails?

> railway shell
Entering subshell with Railway variables available. Type 'exit' to exit.
> railway variables
╔══════════════════════════════ Variables for web ═════════════════════════════╗
...(all the vars are here as expected, including SMTP_USER)...
╚══════════════════════════════════════════════════════════════════════════════╝
> echo $RAILS_ENV
production
> rails c
... `fetch': key not found: "SMTP_USER" (KeyError)
> railway shell
Entering subshell with Railway variables available. Type 'exit' to exit.
> railway variables
╔══════════════════════════════ Variables for web ═════════════════════════════╗
...(all the vars are here as expected, including SMTP_USER)...
╚══════════════════════════════════════════════════════════════════════════════╝
> echo $RAILS_ENV
production
> rails c
... `fetch': key not found: "SMTP_USER" (KeyError)
The code in production.rb that is erroring out is user_name: ENV.fetch('SMTP_USER') Any ideas?
2 Replies
Percy
Percy2y ago
Project ID: 9ddc4dfb-ab3f-4809-8481-9657a0c52a43
chiperific
chiperificOP2y ago
9ddc4dfb-ab3f-4809-8481-9657a0c52a43 I "fixed" this by only relying on Rails.credentials and never ENV.fetch(). However, Rails.credentials relies on RAILS_MASTER_KEY, which it is obviously getting, so the error still seems weird to me.
Want results from more Discord servers?
Add your server