You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support dotenv .env files using export as in export VAR=value #17182
I know VS Code with Pylance supports loading environment variables from a .env (dotenv file), which is great. It allows me to, for example, easily run or debug tests right from the editor, using all the environment variables needed.
Here's the example from the docs:
# API endpoint
MYPROJECT_APIENDPOINT=https://my.domain.com/api/dev/
# Variables for the database
MYPROJECT_DBURL=https://my.domain.com/db/dev
MYPROJECT_DBUSER=devadmin
MYPROJECT_DBPASSWORD=!dfka**213=
Feature Request
I would like VS Code / Pylance to also support defining the variables with export, as in:
# API endpointexport MYPROJECT_APIENDPOINT=https://my.domain.com/api/dev/
# Variables for the databaseexport MYPROJECT_DBURL=https://my.domain.com/db/dev
export MYPROJECT_DBUSER=devadmin
export MYPROJECT_DBPASSWORD=!dfka**213=
This would allow me to use the same set of environment variables from the command line by sourcing that file.
For example I could load the environment:
$ source .env
And then run other commands that would use the same environment variables, for example, to run the tests usingcoverage:
$ coverage run --source ./app/ -m pytest
Current behavior
As Currently VS Code / Pylance doesn't support having export in these .env files, I have to manually add the export before each variable before using it on the command line, and then I have to manually remove those exports manually to run again the tests from inside VS Code.
Apart from the double effort of adding and removing those exports, you can imagine that I often forget I had to do that, and I end up spending a long time debugging "why it's not working" in one place or the other, while it was just that I forgot to add or remove those exports. 😅
Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 5 👍 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.
I rather dislike the voting requirements on these issues as the issue list is huge, and there is little visibility on what FRs might require voting feedback.
It took me a while to figure out that this was the issue I was experiencing; I was assuming export in .env would just work because dotenv and other tools support this so I was searching for other keywords (pytest .env being a prominent one, since I was running into this trying to get pyenv to complete test discovery).
Martijn Pieters (@mjpieters) we are following VS Code for the voting practice where their issue tracker is over 5x larger than ours and they require 20 votes to keep something open.
And plenty of issues have met the threshold so we don't view it as an unreasonable way to gauge community interest. At worst someone opens a duplicate issue and we simply ask them to go upvote the original issue.
Thank you for submitting your feature request and everyone who considered it! Unfortunately this issue did not receive enough votes over the allotted time, and so we are closing the issue.
Activity
brettcannon commentedon Sep 1, 2021
Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 5 👍 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.
mjpieters commentedon Oct 13, 2021
I rather dislike the voting requirements on these issues as the issue list is huge, and there is little visibility on what FRs might require voting feedback.
It took me a while to figure out that this was the issue I was experiencing; I was assuming
exportin .env would just work becausedotenvand other tools support this so I was searching for other keywords (pytest .envbeing a prominent one, since I was running into this trying to get pyenv to complete test discovery).brettcannon commentedon Oct 15, 2021
Martijn Pieters (@mjpieters) we are following VS Code for the voting practice where their issue tracker is over 5x larger than ours and they require 20 votes to keep something open.
And plenty of issues have met the threshold so we don't view it as an unreasonable way to gauge community interest. At worst someone opens a duplicate issue and we simply ask them to go upvote the original issue.
As for visibility, needs community feedbackAwaiting community feedback
is a dedicated label on this topic and is mentioned in the issue management page in our wiki.
brettcannon commentedon Nov 1, 2021
Thank you for submitting your feature request and everyone who considered it! Unfortunately this issue did not receive enough votes over the allotted time, and so we are closing the issue.