"python.envFile": cannot be set to empty string
See original GitHub issueType: 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:
- add
"python.envFile": "",
to the settings - open a python file
- 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 (View
→Output
, 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:
- Created 10 months ago
- Reactions:1
- Comments:5
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks for the quick resolution!
Fix should be out in the pre-release version of the extension in a day, use the following to try it out: