question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

env file not loaded if specified in launch.json and python.envFile

See original GitHub issue

Environment data

  • VS Code version: 1.38.0
  • Extension version (available under the Extensions sidebar): 2019.9.34474
  • OS and version: MAC OS Mojave - 10.14.6
  • Python version (& distribution if applicable, e.g. Anaconda): Pyhton 3.7.2 - 64 bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
  • Relevant/affected Python packages and their versions: XXX
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): Language Server

Issue description

In the latest build, when debugging a python file using integrated terminal, the contents of “.env” file are not being loaded. This issue is not seen in 2019.8.0. I downgraded to verify that this is a regression issue. Content of launch.json file

        {
            "name": "Python: Terminal (integrated)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "envFile": "${workspaceRoot}/.env"
        },

Contents of .env file

PYTHONPATH=/opt/library/python:/opt/lib/PythonApi
TCLLIBPATH="/opt/library /Library/Tcl/teapot/package/macosx10.5-i386-x86_64/lib"

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:13

github_iconTop GitHub Comments

2reactions
DonJayamannecommented, Sep 13, 2019

I have submitted a PR to resolve this issue.

1reaction
martinsteincommented, Sep 12, 2019

So if envFile in the launch configuration is no longer supported, that means there is no easy way to switch between different env-files for different launch configurations anymore? That feature was very helpful, and it’s even nicely documented here: https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-file :

A debug configuration also contains an envFile property that also defaults to the .env file in the current workspace (see Debugging - Set configuration options). This property allows you to easily set variables for debugging purposes that replace variables specified in the default .env file

Now you have to go into settings and modify python.envFile each time when you want to run a launch config with a different env-file?

I’m aware of the env option, but that’s not really a good alternative, because it would mean duplicating the values from the env-files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code "python.envFile" does not seem to work with "python ...
i was facing issue of module not found in vscode then i wrote the ... in VS Code settings files, it will not...
Read more >
Using Python environments in VS Code
All env variables defined in the launch.json file will override variables contained in the .env file, specified by the python.envFile setting (user or...
Read more >
How to use a .env file to load environment variables in a dev ...
Loading environment variables using a . env file when working with Remote - Containers or GitHub Codespaces. Check out the docs for more...
Read more >
How to Set up Environment Variables in "launch.json ...
Nevertheless, as I started debugging, the debugging tool of vscode prepared forever and never entered the real debugging session. How should I ...
Read more >
Run (not debug) python using the .env file : r/vscode - Reddit
Is there a way to run (not debug) a program using the .env file? When I debug, I create a bunch of environment...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found