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

Load .envrc files like direnv. #113

Closed
AndersDJohnson opened this issue Dec 13, 2015 · 5 comments
Closed

Load .envrc files like direnv. #113

AndersDJohnson opened this issue Dec 13, 2015 · 5 comments

Comments

@AndersDJohnson
Copy link

Either in addition to or as a fallback in case of missing .env file, it may be nice to also check for .envrc file, e.g. from direnv, and gracefully attempt to parse & load it.

Probably relies on an implementation of #112.

@maxbeatty
Copy link
Contributor

I'd suggest using the custom path option if you know you're looking for .envrc. It's also harmless to try to attempt to load two or more files yourself.

const dotenv = require('dotenv')
dotenv.config()
dotenv.config({ path: '.envrc' })

@AndersDJohnson
Copy link
Author

Thanks @maxbeatty, I'll try that.

@wilmoore
Copy link

@adjohnson916 This should work for very specific cases where you are absolutely sure that your .envrc file only includes variable assignments; however, it could easily go south if your .envrc file includes other commands which dotenv does not support.

Also, I'm just curious to hear of other people's workflow...if you are already using direnv, why use dotenv locally at all? Shouldn't direnv allow be enough?

@AndersDJohnson
Copy link
Author

@wilmoore I figured. Why? Might not be running the app from the current working directory, or from a different user account e.g. a system account that's not running with a shell and/or doesn't have direnv configured . Might want to use dotenv on a server to provide environment-specific configuration to the deployed application, defaulting to variables specified for local dev in .envrc via direnv.

@wilmoore
Copy link

Thanks @adjohnson916 -- good to know.

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

3 participants