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

dotenv should look up in parent directories for .env #165

Open
cdignam-segment opened this issue Dec 28, 2021 · 6 comments · May be fixed by #166
Open

dotenv should look up in parent directories for .env #165

cdignam-segment opened this issue Dec 28, 2021 · 6 comments · May be fixed by #166

Comments

@cdignam-segment
Copy link

My .env file is at the root of my project, but when running tests, the current working directory is within test modules.

This would match the behavior of https://github.com/dotenv-rs/dotenv/tree/3c1a77bc95821777e5ceb996c5e0b082f2a3ea38#usage and https://github.com/theskumar/python-dotenv.

@joho
Copy link
Owner

joho commented Jan 2, 2022

Yep, you're right. Will bring that feature in as a breaking change

cdignam-segment added a commit to segmentio/godotenv that referenced this issue Jan 4, 2022
@cdignam-segment
Copy link
Author

@joho I made a PR to resolve this issue: #166

It would be great to get your feedback!

@wengtad
Copy link

wengtad commented May 8, 2022

Hi, any updates?

@joho
Copy link
Owner

joho commented Jun 12, 2022

I've been umming and ahhing on this one. I know I was very supportive when originally opened, but ever since I've been worrying about directory traversal attacks.

I'm about to close the door on breaking changes (see #182) but will hopefully include this one before I do (if I can come to comfort on the traversal risks)

@rcy
Copy link

rcy commented May 17, 2024

@joho what's your comfort level at around this now? I'm running into the same issue here with wanting my $PROJECT_ROOT/.env.test to be loaded when running go tests. Any suggested workarounds would be appreciated as well!

@kirici
Copy link

kirici commented Oct 12, 2024

@rcy

Any suggested workarounds would be appreciated as well!

direnv, if set, checks and loads .env/.envrc in parent directories as well, making them available to your shell. That comes with the added benefit of not having to load/source the same file in every application/script.

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

Successfully merging a pull request may close this issue.

5 participants