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

Make auto-loading .env files optional with a setting to turn it off #23575

Open
nfarahmand opened this issue Jun 7, 2024 · 5 comments
Open
Assignees
Labels
area-testing community ask Feature request that the community expressed interest in feature-request Request for new features or functionality needs community feedback Awaiting community feedback

Comments

@nfarahmand
Copy link

The Python extension looks for and loads the .env file within a workspace, which loads those variables into the environment for tests and the integrated terminal. This feature should be made optional with a setting to turn it off. The .env file in a workspace often is not the settings someone would like to use when running unit tests, so tests will fail with those settings. Without a way to turn it off, I have to either comment out the .env file before running unit tests, or go to another terminal outside of VS Code to run my tests.

Please make the auto-loading of .env files in a workspace optional with a setting to turn it off.

@vscodenpa vscodenpa added the triage-needed Needs assignment to the proper sub-team label Jun 7, 2024
@Yoyokrazy Yoyokrazy assigned eleanorjboyd and unassigned Yoyokrazy Jun 7, 2024
@vscodenpa vscodenpa removed the triage-needed Needs assignment to the proper sub-team label Jun 7, 2024
@eleanorjboyd
Copy link
Member

Hi! To clarify is this primarily with tests you have this problem or with all parts of your setup?

@nfarahmand
Copy link
Author

Yeah it mostly becomes a problem when I run tests, both from within the VS Code UI and through the integrated terminal. In both instances, they have the environment variables loaded but those variables mess up the tests. The .env file is read when my app starts up so I don't see a need to have it auto-loaded into the env (at least not for any of my use cases).

@eleanorjboyd eleanorjboyd transferred this issue from microsoft/vscode Jun 7, 2024
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jun 7, 2024
@eleanorjboyd eleanorjboyd added feature-request Request for new features or functionality area-testing needs community feedback Awaiting community feedback community ask Feature request that the community expressed interest in and removed triage-needed Needs assignment to the proper sub-team labels Jun 7, 2024
Copy link

github-actions bot commented Jun 7, 2024

Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

@idreyn
Copy link

idreyn commented Jun 7, 2024

yes +1 to this, I was recently bitten by this. To me .env is for vars that my app runs on, not that I want loaded into my shell — those can be very different! I'm sure many VSCode users find it useful, but personally I would want it off by default.

@itrew
Copy link

itrew commented Jan 23, 2025

Agreed, this feature should either be optional or removed. This one bit me while working on a completely unrelated Node project.

In my instance, I oftentimes switch between JS and Python, and I have extensions installed for both use cases. For my Node projects, I have multiple .env files for different deployment modes, all automatically loaded by Vite. The last thing I was expecting was for a Python extension to start auto injecting (and aggressively caching) specified environment variables prior to running my node server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-testing community ask Feature request that the community expressed interest in feature-request Request for new features or functionality needs community feedback Awaiting community feedback
Projects
None yet
Development

No branches or pull requests

6 participants