Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] Clarify Behavior When Using Environment Specific .env Alongside a Generic .env in README #68

Closed
Undistraction opened this issue Oct 30, 2013 · 5 comments

Comments

@Undistraction
Copy link

From trawling through the issues it appears that Dotenv will load a .env file and then any environment specific files: env.staging etc.

However this isn't clear from the README. Please add clarification for the behaviour:

  1. Does Dotenv always load a .env file even if there is an environmental specific file aswell? In what order?
  2. If so, and a variable is defined in the .env file, what happens if it is defined again in the environmental specific file? Is it overridden?

It would also be worth mentioning that Dotenv is used by Foreman as I think that is a good selling point.

@allaire
Copy link

allaire commented Nov 4, 2013

Yes, clarification would be gladly appreciated. Meanwhile, can anyone explain @1ndivisible 's questions?

Thanks!

@nelsonenzo
Copy link

Along these lines, are there extra configuration requirements for it to load the .env.development file? I can only define variables in .env right now, using Rails 2.3.5., the .env.development does not appear to be loading when I start the application.

@Undistraction
Copy link
Author

@nelsonenzo

From dotenv/lib/dotenv/railtie.rb you can see that Dotenv loads two files. A file called .env and a file whos name is build using .env. suffixed by the the name of the current environment:

Dotenv.load ".env.#{Rails.env}", '.env'

@chischaschos
Copy link

I'm under the same confusion, I thought the .env.ENVIRONMENT files would be up loaded automatically, but it doesn't.

I read this https://github.com/bkeepers/dotenv/blob/master/lib/dotenv/railtie.rb#L14, so basically if you don't use rails you need to manually indicate the .env files you want (when using environment specific settings).

I think the README should specify this.

I ended up doing this: https://github.com/chischaschos/scanty/blob/master/main.rb#L5

@bkeepers
Copy link
Owner

Pull requests are welcome.

Note that the auto-loading of ".env.#{Rails.env}" is going to be split out into a separate gem soon (#95).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants