Skip to content

Add direnv .envrc to python gitignore #3619

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

fslds
Copy link

@fslds fslds commented Jan 7, 2021

Reasons for making this change:

The direnv project (https://direnv.net/ ) uses .envrc files for dynamically loading environment variables (or other settings) per directory using the user's shell... As it can contain sensitive information, and is similar in goal as to dotenv etc, I think it is a good idea to exclude this by default as well into popular languages that already can use a 'dotenv' .env file as well. Adding this to the python .gitignore.

Links to documentation supporting these rule changes:

The direnv project (https://direnv.net/ )  uses .envrc files for dynamically loading environment variables (or other settings) per directory using the user's shell.. As it can contain sensitive information, and is similar in goal as to .env etc, I think it is a good idea to exclude this by default as well.
@garrison
Copy link

One might want to intentionally add an .envrc file to the repository, e.g., one that includes the single line layout python3. In this case, .direnv should be added to .gitignore, but .envrc shouldn't be.

In fact, it is safe to exclude .direnv in all cases. I came here to submit a pull request that adds .direnv to .gitignore for python (really it could be added for every single language). But I don't believe that .envrc should be added.

@garrison
Copy link

In other words, while .envrc can contain secrets, that is not the sole purpose of direnv.

@fslds
Copy link
Author

fslds commented Dec 5, 2021

That is actually correct, but the likelihood is large that a secret ends up in the .envrc file, and this is an effort to increase overall security.
By adding it to the general .gitignore, - and yes it should be added for each language - it needs to be uncommented explicitly, making it a conscious action...
That being said I would recommend using the dotenv command or source .env in .envrc and store secrets in the more commonly used .env.
I switched to that workflow myself in the meanwhile 😇 .

Copy link

github-actions bot commented Jun 2, 2025

This PR is stale because there have been no updates in 90 days. It will close after 180 days of inactivity. Leave a comment if you want to keep it open 😄

@github-actions github-actions bot added the stale label Jun 2, 2025
@garrison
Copy link

garrison commented Jun 2, 2025

In case my 👍 was overlooked... I am nowadays in favor of both .envrc and .direnv being included in gitignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants