Repository navigation
Description
Issue Type: Bug
Summary
I already have an issue open around the fact that on ubuntu I need to launch vscode from terminal, otherwise vscode itself can't open a terminal
microsoft/vscode-python#10985
If I start vscode from my terminal (bash), the terminal within vscode is missing a lot of environment variables, such as $DISPLAY. Interestingly, the Python interactive Window does have these variables!
Steps to reproduce:
- Launch vscode (from terminal)
- Open terminal
echo $DISPLAYwill return blank
Alternatively
- Launch code (from terminal)
- Create py file containing
import os; os.environ['DISPLAY'] - Run in Python Interactive Window => works
- Run in Python Terminal => fails with KEYERROR
Additional notes
-
the issue isn't Python vs IPython, because:
a) even running in IPython in terminal still gives the same error.
b) becauseecho $DISPLAYin the terminal is blank anyway -
.bashrcis loaded in vscode's terminal (I can see my custom environment variables), it's just system defined env vars such as $DISPLAY which are missing.
I've also included a full diff of pprint(os.environ.dict) from both Python Terminal, and Python InteractiveWindow so you can see how much is different.
--- test/env_terminal.txt
+++ test/env_interactive.txt
@@ -1,15 +1,47 @@
-{'_data': {b'COLORTERM': b'truecolor',
+{'_data': {b'AMD_ENTRYPOINT': b'vs/workbench/services/extensions/node/extens'
+ b'ionHostProcess',
+ b'APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL': b'true',
+ b'CHROME_DESKTOP': b'code-url-handler.desktop',
+ b'CLICOLOR': b'1',
+ b'CLUTTER_IM_MODULE': b'xim',
+ b'COLORTERM': b'truecolor',
b'CONDA_DEFAULT_ENV': b'base',
b'CONDA_EXE': b'/home/memo/anaconda3/bin/conda',
b'CONDA_PREFIX': b'/home/memo/anaconda3',
b'CONDA_PROMPT_MODIFIER': b'(base) ',
b'CONDA_PYTHON_EXE': b'/home/memo/anaconda3/bin/python',
b'CONDA_SHLVL': b'1',
+ b'CUDA_HOME': b'/usr/local/cuda',
+ b'DBUS_SESSION_BUS_ADDRESS': b'unix:path=/run/user/1000/bus',
+ b'DEFAULTS_PATH': b'/usr/share/gconf/ubuntu.default.path',
+ b'DESKTOP_AUTOSTART_ID': b'10c85e4a0fadb463e11586356093168402000000'
+ b'68180007',
+ b'DESKTOP_SESSION': b'ubuntu',
b'DEV_PATH': b'/home/memo/Dropbox/dev',
+ b'DISABLE_WAYLAND': b'1',
+ b'DISPLAY': b':1',
b'DROPBOX_PATH': b'/home/memo/Dropbox',
+ b'ELECTRON_NO_ATTACH_CONSOLE': b'1',
+ b'ELECTRON_RUN_AS_NODE': b'1',
+ b'GDK_PIXBUF_MODULEDIR': b'/snap/code/28/usr/lib/x86_64-linux-gnu/g'
+ b'dk-pixbuf-2.0/2.10.0/loaders',
+ b'GDK_PIXBUF_MODULE_FILE': b'/home/memo/snap/code/common/.cache/g'
+ b'dk-pixbuf-loaders.cache',
+ b'GDMSESSION': b'ubuntu',
+ b'GIT_PAGER': b'cat',
+ b'GNOME_DESKTOP_SESSION_ID': b'this-is-deprecated',
+ b'GNOME_SHELL_SESSION_MODE': b'ubuntu',
+ b'GNOME_TERMINAL_SCREEN': b'/org/gnome/Terminal/screen/b590a0b5_4df6'
+ b'_4b60_bbec_bd8afd6c7e15',
+ b'GNOME_TERMINAL_SERVICE': b':1.744',
+ b'GPG_AGENT_INFO': b'/run/user/1000/gnupg/S.gpg-agent:0:1',
+ b'GSETTINGS_SCHEMA_DIR': b'/snap/code/28/usr/share/glib-2.0/schemas',
+ b'GTK_IM_MODULE': b'ibus',
+ b'GTK_MODULES': b'gail:atk-bridge',
b'HOME': b'/home/memo',
- b'INVOCATION_ID': b'ce824669c3444d9ca49b3b3b72b66dfa',
- b'JOURNAL_STREAM': b'9:54941',
+ b'IM_CONFIG_PHASE': b'2',
+ b'JPY_PARENT_PID': b'23256',
+ b'KERNEL_LAUNCH_TIMEOUT': b'40',
b'LANG': b'en_US.UTF-8',
b'LESSCLOSE': b'/usr/bin/lesspipe %s %s',
b'LESSOPEN': b'| /usr/bin/lesspipe %s',
@@ -43,30 +75,92 @@
b'=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00'
b';36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*'
b'.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:',
- b'NOTIFY_SOCKET': b'/run/systemd/notify',
+ b'MANDATORY_PATH': b'/usr/share/gconf/ubuntu.mandatory.path',
+ b'MPLBACKEND': b'module://ipykernel.pylab.backend_inline',
+ b'PAGER': b'cat',
b'PATH': b'/home/memo/anaconda3/bin:/home/memo/anaconda3/condabin:/'
- b'home/memo/.local/bin:/home/memo/bin:/home/memo/Dropbox/s'
- b'cripts/ubuntu:/home/memo/Dropbox/research/py/utils:/home'
- b'/memo/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/'
- b'sbin:/usr/bin:/sbin:/bin:/snap/bin',
- b'PWD': b'/home/memo/Downloads/test',
- b'PYTHONIOENCODING': b'UTF-8',
- b'PYTHONPATH': b':/home/memo/Dropbox/research/pypackages',
+ b'usr/local/cuda/bin:/home/memo/.local/bin:/home/memo/bin:'
+ b'/home/memo/Dropbox/scripts/ubuntu:/home/memo/Dropbox/res'
+ b'earch/py/utils:/home/memo/anaconda3/bin:/usr/local/sbin:'
+ b'/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:'
+ b'/usr/local/games:/snap/bin',
+ b'PIPE_LOGGING': b'true',
+ b'PWD': b'/home/memo',
+ b'PYTHONIOENCODING': b'utf-8',
+ b'PYTHONPATH': b':/home/memo/Dropbox/research/pypackages:/home/me'
+ b'mo/Dropbox/research/pypackages:/home/memo/.vscod'
+ b'e/extensions/ms-python.python-2020.3.71659/pytho'
+ b'nFiles:/home/memo/.vscode/extensions/ms-python.p'
+ b'ython-2020.3.71659/pythonFiles/lib/python',
b'PYTHONUNBUFFERED': b'1',
+ b'PYTHONWARNINGS': b'ignore',
+ b'QT4_IM_MODULE': b'xim',
+ b'QT_ACCESSIBILITY': b'1',
+ b'QT_IM_MODULE': b'ibus',
b'RESEARCH_PATH': b'/home/memo/Dropbox/research',
+ b'SESSION_MANAGER': b'local/MSA-BLADE15-UBUNTU:@/tmp/.ICE-unix/681'
+ b'8,unix/MSA-BLADE15-UBUNTU:/tmp/.ICE-unix/6818',
b'SHELL': b'/bin/bash',
- b'SHLVL': b'1',
- b'TERM': b'xterm-256color',
- b'TERM_PROGRAM': b'vscode',
- b'TERM_PROGRAM_VERSION': b'1.43.2',
+ b'SHLVL': b'3',
+ b'SNAP': b'/snap/code/28',
+ b'SNAP_ARCH': b'amd64',
+ b'SNAP_COMMON': b'/var/snap/code/common',
+ b'SNAP_CONTEXT': b'qgD6cMsPjdq5SdjsPNtSFN1Rx8xF94jpC32BMqFCcp8c',
+ b'SNAP_COOKIE': b'qgD6cMsPjdq5SdjsPNtSFN1Rx8xF94jpC32BMqFCcp8c',
+ b'SNAP_DATA': b'/var/snap/code/28',
+ b'SNAP_INSTANCE_KEY': b'',
+ b'SNAP_INSTANCE_NAME': b'code',
+ b'SNAP_LIBRARY_PATH': b'/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl3'
+ b'2:/var/lib/snapd/void',
+ b'SNAP_NAME': b'code',
+ b'SNAP_REEXEC': b'',
+ b'SNAP_REVISION': b'28',
+ b'SNAP_USER_COMMON': b'/home/memo/snap/code/common',
+ b'SNAP_USER_DATA': b'/home/memo/snap/code/28',
+ b'SNAP_VERSION': b'0ba0ca52',
+ b'SSH_AGENT_PID': b'6924',
+ b'SSH_AUTH_SOCK': b'/run/user/1000/keyring/ssh',
+ b'TERM': b'xterm-color',
+ b'TEXTDOMAIN': b'im-config',
+ b'TEXTDOMAINDIR': b'/usr/share/locale/',
b'USER': b'memo',
- b'XDG_RUNTIME_DIR': b'/run/user/1000',
- b'_': b'/usr/bin/env',
+ b'USERNAME': b'memo',
+ b'VERBOSE_LOGGING': b'true',
+ b'VSCODE_CLI': b'1',
+ b'VSCODE_HANDLES_UNCAUGHT_ERRORS': b'true',
+ b'VSCODE_IPC_HOOK': b'/run/user/1000/snap.code/vscode-8d12be21-1.4'
+ b'3.2-main.sock',
+ b'VSCODE_IPC_HOOK_EXTHOST': b'/tmp/vscode-ipc-8e622085-d41d-4290-8'
+ b'43b-0d3e14392b09.sock',
+ b'VSCODE_LOGS': b'/home/memo/.config/Code/logs/20200408T191056',
+ b'VSCODE_LOG_STACK': b'false',
+ b'VSCODE_NLS_CONFIG': b'{"locale":"en-us","availableLanguages":{},"_'
+ b'languagePackSupport":true}',
+ b'VSCODE_NODE_CACHED_DATA_DIR': b'/home/memo/.config/Code/CachedDa'
+ b'ta/0ba0ca52957102ca3527cf4795716'
+ b'17f0de6ed50',
+ b'VSCODE_PID': b'18961',
+ b'VTE_VERSION': b'5202',
+ b'WINDOWPATH': b'2',
+ b'XAUTHORITY': b'/run/user/1000/gdm/Xauthority',
+ b'XDG_CONFIG_DIRS': b'/etc/xdg/xdg-ubuntu:/etc/xdg',
+ b'XDG_CURRENT_DESKTOP': b'Unity',
+ b'XDG_DATA_DIRS': b'/usr/share/ubuntu:/usr/local/share/:/usr/share/:'
+ b'/var/lib/snapd/desktop',
+ b'XDG_MENU_PREFIX': b'gnome-',
+ b'XDG_RUNTIME_DIR': b'/run/user/1000/snap.code',
+ b'XDG_SEAT': b'seat0',
+ b'XDG_SESSION_DESKTOP': b'ubuntu',
+ b'XDG_SESSION_ID': b'2',
+ b'XDG_SESSION_TYPE': b'x11',
+ b'XDG_VTNR': b'2',
+ b'XMODIFIERS': b'@im=ibus',
+ b'_': b'/home/memo/anaconda3/bin/python',
b'_CE_CONDA': b'',
b'_CE_M': b''},
- 'decodekey': <function _createenviron.<locals>.decode at 0x7f9a57a34f28>,
- 'decodevalue': <function _createenviron.<locals>.decode at 0x7f9a57a34f28>,
- 'encodekey': <function _createenviron.<locals>.encode at 0x7f9a57a34ea0>,
- 'encodevalue': <function _createenviron.<locals>.encode at 0x7f9a57a34ea0>,
+ 'decodekey': <function _createenviron.<locals>.decode at 0x7fe7f6fa5950>,
+ 'decodevalue': <function _createenviron.<locals>.decode at 0x7fe7f6fa5950>,
+ 'encodekey': <function _createenviron.<locals>.encode at 0x7fe7f6fa58c8>,
+ 'encodevalue': <function _createenviron.<locals>.encode at 0x7fe7f6fa58c8>,
'putenv': <built-in function putenv>,
'unsetenv': <built-in function unsetenv>}
VS Code version: Code 1.43.2 (0ba0ca5, 2020-03-24T07:52:11.516Z)
OS version: Linux x64 5.3.0-46-generic snap
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 x 4000) |
| GPU Status | 2d_canvas: enabled flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: disabled_off protected_video_decode: unavailable_off rasterization: disabled_software skia_renderer: disabled_off_ok video_decode: unavailable_off viz_display_compositor: enabled_on viz_hit_test_surface_layer: disabled_off_ok webgl: enabled webgl2: enabled |
| Load (avg) | 1, 1, 1 |
| Memory (System) | 15.54GB (0.63GB free) |
| Process Argv | --no-sandbox |
| Screen Reader | no |
| VM | 0% |
Extensions (8)
| Extension | Author (truncated) | Version |
|---|---|---|
| gitignore | cod | 0.6.0 |
| vscode-eslint | dba | 2.1.2 |
| vscode-firefox-debug | fir | 2.7.1 |
| asciidecorator | hel | 0.2.0 |
| beautify | Hoo | 1.5.0 |
| python | ms- | 2020.3.71659 |
| cpptools | ms- | 0.27.0 |
| debugger-for-chrome | msj | 4.12.6 |
Activity
Tyriar commentedon Apr 8, 2020
Do you set the inheritEnv setting? Can you share your settings.json file?
memoakten commentedon Apr 9, 2020
Hi, I did not have that option enabled, I didn't know about it! I enabled it, and now it does work, thanks!.
On a side note, when I launch vscode, I get this popup warning: "We noticed you're using a conda environment. If you are experiencing issues with this environment in the integrated terminal, we recommend that you let the Python extension change "terminal.integrated.inheritEnv" to false in your user settings. Yes/No". It's very likely that I might have chosen yes for that if it asked me in the past and this is the first time I'm needing those env variables.
Tyriar commentedon Apr 13, 2020
/duplicate #76542