简体   繁体   中英

foreman not getting environment variables

I'm using foreman for the environment variables in a rails app. On my config/enviroments/development.rb I have the following code:

config.action_mailer.smtp_settings = { 
  address: "smtp.gmail.com",
  port: "587",
  domain: "gmail.com",
  authentication: "plain", 
  enable_starttls_auto: true,
  user_name: ENV['GMAIL_USERNAME'],
  password: ENV['GMAIL_PASSWORD'] 
  #user_name: "user@gmail.com",                    
  #password: "password"
}

and my .env file is as follows:

GMAIL_USERNAME=user@gmail.com
GMAIL_PASSWORD=password

and my Procfile is:

web: bundle exec rvmsudo rails s -p 80

So if I run "foreman start", I get the following message:

Net::SMTPAuthenticationError in Devise::ConfirmationsController#create 530-5.5.1 Authentication Required

However if I comment the lines that concern the environment variables and uncomment the ones that are commented right now at development.rb, everything works fine.

So I imagine the problem is that foreman is not getting the environment variables correctly. I'm using git with branches, and ignoring both Procfile and .env

Is there anything wrong with my code?

Looks like the environment variables are not being set. Which method are you using to do that? Here's an article that explains several methods.

Try setting them manually on the command line thus:

export GMAIL_USERNAME="user@gmail.com"
export GMAIL_PASSWORD="password"

Then type env at the command prompt to verify they are set. Then give it a whirl.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM