Type: Bug
Behaviour
Bug Description
The .env file parser in the Python extension does not support multiline environment variables, breaking compatibility with the standard python-dotenv library and causing corrupted/truncated values to be passed to Jupyter kernels.
Steps to reproduce:
1. Create a .env file with a multiline variable
Create a file named .env in your workspace root:
TEST_ENV_VAR_MULTILINE='{
"key1": "value1",
"key2": "value2"
}'
TEST_ENV_VAR_SIMPLE='simple_value'
2. Create a Jupyter notebook and check the environment
Create a new Jupyter notebook (.ipynb) and run this code in the first cell (before any load_dotenv() or imports):
import os
print("Simple var:", os.environ.get('TEST_ENV_VAR_SIMPLE'))
print("Multiline var:", repr(os.environ.get('TEST_ENV_VAR_MULTILINE')))
3. Observe the bug
Expected output:
Simple var: 'simple_value'
Multiline var: '{\n "key1": "value1",\n "key2": "value2"\n}'
Actual output:
Simple var: 'simple_value'
Multiline var: "'{"
The multiline variable is truncated to just the first line!
4. Compare with regular Python script
Run the same code in a regular Python script (not Jupyter):
# test.py
from dotenv import load_dotenv
import os
load_dotenv()
print("Multiline var:", repr(os.environ.get('TEST_ENV_VAR_MULTILINE')))
$ python test.py
Multiline var: '{\n "key1": "value1",\n "key2": "value2"\n}' ✅ Works correctly!
Extension version: 2025.14.0
VS Code version: Code 1.104.1 (0f0d87fa9e96c856c5212fc86db137ac0d783365, 2025-09-17T23:36:24.973Z)
OS version: Linux x64 6.8.0-79-generic
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.11.13
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServer setting: Default
User Settings
venvPath: "<placeholder>"
languageServer: "Pylance"
Installed Extensions
| Extension Name |
Extension Id |
Version |
| claude-code |
Ant |
2.0.0 |
| copilot |
Git |
1.372.0 |
| copilot-chat |
Git |
0.31.3 |
| js-debug |
ms- |
1.104.0 |
| js-debug-companion |
ms- |
1.1.3 |
| jupyter |
ms- |
2025.8.0 |
| jupyter-keymap |
ms- |
1.1.2 |
| jupyter-renderers |
ms- |
1.3.0 |
| material-theme |
zhu |
3.19.0 |
| pylint |
ms- |
2025.2.0 |
| python |
ms- |
2025.14.0 |
| rainbow-csv |
mec |
3.22.0 |
| remote-containers |
ms- |
0.427.0 |
| ruff |
cha |
2025.26.0 |
| vscode-js-profile-table |
ms- |
1.0.10 |
| vscode-jupyter-cell-tags |
ms- |
0.1.9 |
| vscode-jupyter-slideshow |
ms- |
0.1.6 |
| vscode-pylance |
ms- |
2025.8.3 |
| vscode-python-envs |
ms- |
1.8.0 |
System Info
| Item |
Value |
| CPUs |
Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz (4 x 2900) |
| GPU Status |
2d_canvas: enabled direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off trees_in_viz: disabled_off video_decode: enabled video_encode: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off webnn: disabled_off |
| Load (avg) |
5, 4, 4 |
| Memory (System) |
31.23GB (15.46GB free) |
| Process Argv |
|
| Screen Reader |
no |
| VM |
0% |
| DESKTOP_SESSION |
ubuntu-xorg |
| XDG_CURRENT_DESKTOP |
Unity |
| XDG_SESSION_DESKTOP |
ubuntu-xorg |
| XDG_SESSION_TYPE |
x11 |
Type: Bug
Behaviour
Bug Description
The
.envfile parser in the Python extension does not support multiline environment variables, breaking compatibility with the standardpython-dotenvlibrary and causing corrupted/truncated values to be passed to Jupyter kernels.Steps to reproduce:
1. Create a
.envfile with a multiline variableCreate a file named
.envin your workspace root:2. Create a Jupyter notebook and check the environment
Create a new Jupyter notebook (
.ipynb) and run this code in the first cell (before anyload_dotenv()or imports):3. Observe the bug
Expected output:
Actual output:
The multiline variable is truncated to just the first line!
4. Compare with regular Python script
Run the same code in a regular Python script (not Jupyter):
Extension version: 2025.14.0
VS Code version: Code 1.104.1 (0f0d87fa9e96c856c5212fc86db137ac0d783365, 2025-09-17T23:36:24.973Z)
OS version: Linux x64 6.8.0-79-generic
Modes:
python.languageServersetting: DefaultUser Settings
Installed Extensions
System Info
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off