microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.65k stars 28.68k forks source link

Running VSC with --list-extensions parameter fails on Linux through SSH if X is not running #165614

Closed C0rn3j closed 1 year ago

C0rn3j commented 1 year ago

Type: Bug

This works if running a GUI X session, but not with wayland.

I don't understand why there is a graphical requirement to get STDOUT with a list of installed extensions.

This breaks roles like https://github.com/gantsign/ansible-role-visual-studio-code-extensions/issues/117.

On some configurations this can be worked around with XDG_SESSION_TYPE=wayland, like on my desktop with Nvidia GPU, but my hybrid setup with AMD iGPU + Nvidia dGPU will fail anyway.

Working:

[0] % /usr/bin/code --list-extensions                
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
denoland.vscode-deno
eamodio.gitlens
hediet.vscode-drawio
ms-python.isort
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.vscode-jupyter-slideshow
ms-vscode.cpptools
oderwat.indent-rainbow
redhat.ansible
redhat.vscode-yaml
timonwong.shellcheck
vsciot-vscode.vscode-arduino

Broken:

[0] % ssh localhost '/usr/bin/code --list-extensions'
[79987:1105/192157.114095:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[79987:1105/192157.114149:ERROR:env.cc(226)] The platform failed to initialize.  Exiting.
The futex facility returned an unexpected error code.

VS Code version: Code - OSS 1.73.0 (8fa188b2b301d36553cbc9ce1b0a146ccb93351f, 2022-11-03T14:04:08.642Z) OS version: Linux x64 6.0.6-arch1-1 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 5800H with Radeon Graphics (16 x 3472)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
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_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|0, 1, 1| |Memory (System)|27.27GB (19.66GB free)| |Process Argv|--unity-launch| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|plasmawayland| |XDG_CURRENT_DESKTOP|KDE| |XDG_SESSION_DESKTOP|KDE| |XDG_SESSION_TYPE|wayland|
Extensions (17) Extension|Author (truncated)|Version ---|---|--- vscode-deno|den|3.14.0 gitlens|eam|13.0.4 vscode-drawio|hed|1.6.4 isort|ms-|2022.4.0 python|ms-|2022.18.1 vscode-pylance|ms-|2022.11.10 jupyter|ms-|2022.9.1202862440 jupyter-keymap|ms-|1.0.0 jupyter-renderers|ms-|1.0.12 vscode-jupyter-cell-tags|ms-|0.1.6 vscode-jupyter-slideshow|ms-|0.1.5 cpptools|ms-|1.12.4 indent-rainbow|ode|8.3.1 ansible|red|1.0.90 vscode-yaml|red|1.10.1 shellcheck|tim|0.26.3 vscode-arduino|vsc|0.4.12
dpeukert commented 1 year ago

This also applies to --install-extension, --uninstall-extension and --show-versions. As far as I can tell, this seems to be a regression, as I have used --install-extension before with no active X/Wayland session in my unattended install script with no issues.

(running the same VS Code and OS versions as @C0rn3j)

$ DISPLAY='' code --install-extension 'mikestead.dotenv'
[115774:1108/015026.257554:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[115774:1108/015026.257595:ERROR:env.cc(226)] The platform failed to initialize.  Exiting.
The futex facility returned an unexpected error code.
Aborted (core dumped)

$ DISPLAY='' code --uninstall-extension 'mikestead.dotenv'
[115915:1108/015136.827910:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[115915:1108/015136.827950:ERROR:env.cc(226)] The platform failed to initialize.  Exiting.
The futex facility returned an unexpected error code.
Aborted (core dumped)

$ DISPLAY='' code --show-versions
[116029:1108/015219.422123:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[116029:1108/015219.422163:ERROR:env.cc(226)] The platform failed to initialize.  Exiting.
The futex facility returned an unexpected error code.
Aborted (core dumped)
aeschli commented 1 year ago

/usr/bin/code should link to the shell script in the bin folder which runs Electron with ELECTRON_RUN_AS_NODE=1. Can you verify that?

Running it should not require DISPLAY. I was not able to reproduce it on Ubuntu.

How do you run Code OSS?

C0rn3j commented 1 year ago

[0] % file /usr/bin/code
/usr/bin/code: symbolic link to /usr/bin/code-oss

[0] % file /usr/bin/code-oss
/usr/bin/code-oss: Bourne-Again shell script, ASCII text executable

Which is this file: https://github.com/archlinux/svntogit-community/blob/packages/code/trunk/code.sh

Adding ELECTRON_RUN_AS_NODE=1 before the exec makes it run.

Seems like this is indeed an upstream option

https://github.com/microsoft/vscode/blob/main/scripts/code.sh#L61

I'll open a bug on Arch's tracker.

EDIT: https://bugs.archlinux.org/task/76483

dpeukert commented 1 year ago

Huh, this might be an Arch issue then, IIRC, ELECTRON_RUN_AS_NODE might have been removed at some point from the script Arch uses. Will look into it.

EDIT: wasn’t fast enough ;)