1

I am SSH'd into an OpsWorks Rails App Server and I'm trying to start the Rails console.

This is what I do:

cd /srv/www/appname/current/
RAILS_ENV=production bundle exec rails console

But I get an error because the settings file is expecting environment variables to be present from the OpsWorks config, but they aren't:

in `fetch': key not found: "ELASTICSEARCH_URL" (KeyError)

Form this code:

elasticsearch_url: <%= ENV.fetch('ELASTICSEARCH_URL') %>

The app starts fine and I can use the search feature, so the env vars are clearly getting to the webserver OK. However, when I run printenv from the command line, there is no sign of them. How can I start the console and include the env vars that OpsWorks has provided to the webserver (Unicorn)?

Matt Gibson
  • 14,616
  • 7
  • 47
  • 79
  • if you read this blog post it appears those variables are not made available to the shell (http://blogs.aws.amazon.com/application-management/post/Tx2G95J53SKI2E0/AWS-OpsWorks-supports-application-environment-variables ) – Doon Jan 13 '15 at 01:46
  • I think this may be a dup of (http://stackoverflow.com/questions/28776805/aws-opsworks-environment-variables-not-working)... but it's funny because your question was asked first. ANYWAY, I think I answered your question: http://stackoverflow.com/a/29080651/224334 – RyanWilcox Mar 16 '15 at 15:40

0 Answers0