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.

"python.envFile": cannot be set to empty string

See original GitHub issue

Type: Bug

Behaviour

Setting "python.envFile": "" to disable env file leads to an error. [ERROR 2022-10-8 11:18:1.64]: Unable to read `python.envFile` setting for resource undefined

This may also cause additional errors like the following, but I think it's caused by the wrong parsing of the empty string
[ERROR 2022-10-8 10:50:29.348]: Error discovering pytest tests:
 [TypeError: Cannot read properties of undefined (reading 'join')
	at m.getEnvFile (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:324061)
	at m.getCustomEnvironmentVariables (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:323390)
	at m._getEnvironmentVariables (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:322793)
	at m.getEnvironmentVariables (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:322034)
	at l.create (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:231016)
	at S.create (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:235661)
	at S.createActivatedEnvironment (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:236231)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async a.runTestDiscovery (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:752340)
	at async Promise.all (index 0)
	at async E.refreshTestData (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:782198)
	at async C.refreshTestDataInternal (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:769229)
	at async c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:770055
	at async Promise.all (index 0)
	at async C.refreshTestDataInternal (c:\Users\csl\.vscode\extensions\ms-python.python-2022.18.1\out\client\extension.js:2:769962)
	at async s.$refreshTests (c:\Users\csl\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:94:166907)]

Setting it instead to a non existing file, or even " " (space) works as expected.

This bug seems caused by the version 2022.18.x of the extension, the previous version worked fine

Expected vs. Actual

No error to be produced and the behaviour to be as if the env file does not exists

Steps to reproduce:

  1. add "python.envFile": "", to the settings
  2. open a python file
  3. view the python output log

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.6
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Pylance
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

[ERROR 2022-10-8 11:18:1.64]: Unable to read `python.envFile` setting for resource undefined
[ERROR 2022-10-8 11:18:1.64]: Unable to read `python.envFile` setting for resource {"$mid":1,"external":"file:///c%3A/Users/csl/dev/python-test","path":"/c:/Users/csl/dev/python-test","scheme":"file"}
[ERROR 2022-10-8 11:18:1.77]: Unable to read `python.envFile` setting for resource {"$mid":1,"external":"file:///c%3A/Users/csl/dev/python-test","path":"/c:/Users/csl/dev/python-test","scheme":"file"}
[ERROR 2022-10-8 11:18:1.79]: Unable to read `python.envFile` setting for resource {"$mid":1,"external":"file:///c%3A/Users/csl/dev/python-test","path":"/c:/Users/csl/dev/python-test","scheme":"file"}
[ERROR 2022-10-8 11:18:1.82]: Unable to read `python.envFile` setting for resource {"$mid":1,"external":"file:///c%3A/Users/csl/dev/python-test","path":"/c:/Users/csl/dev/python-test","scheme":"file"}

User Settings


envFile: ""

languageServer: "Pylance"

linting
• flake8Enabled: true

formatting
• provider: "black"

testing
• autoTestDiscoverOnSaveEnabled: false

Extension version: 2022.18.1 VS Code version: Code 1.73.0 (8fa188b2b301d36553cbc9ce1b0a146ccb93351f, 2022-11-01T15:34:06.111Z) OS version: Windows_NT x64 10.0.19044 Modes: Sandboxed: No

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes516:30244333
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
pyindex848cf:30577861
nodejswelcome1:30587005
fc301958:30595537
282f8724:30602487
gswce2:30605431
3d0df643:30604793
dbltrim-noruby:30604474

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
CaselITcommented, Nov 9, 2022

thanks for the quick resolution!

0reactions
karrtikrcommented, Nov 9, 2022

Fix should be out in the pre-release version of the extension in a day, use the following to try it out:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot define empty environment variable with Pipenv .env ...
I activated the virtual environment with pipenv shell and expected variable BAR to be an empty string, but it was not defined at...
Read more >
Using AWS Lambda environment variables
An environment variable is a pair of strings that is stored in a function's version-specific configuration. The Lambda runtime makes environment variables ...
Read more >
How to use pydantic to read environment variables and secret ...
The default prefix is an empty string. The prefix can be set by the env_prefix property in the Config inner class. To specify...
Read more >
about Environment Variables - PowerShell | Microsoft Learn
Environment variables, unlike other types of variables in PowerShell, are always stored as a string and can't be empty.
Read more >
Serverless Dotenv Plugin
Use this plugin if you have variables stored in a .env file that you want ... If for some reason you can't set...
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