vscode: Cannot open source files from within file manager (Thunar)

Type: Bug

After the most recent update when I double click source files (*.php, *.js, etc.) a new instance of VS code is spawned and nothing is opened, neither in the already open vs code instance nor in the new one.

Files could be opened by dropping them on VS code window and by using the explorer as well as using search results.

My dev box has Xubuntu 20.04 and the file manager I use is Thunar. Here is the version information from the “About” dialog:

Version: 1.89.0 Commit: b58957e67ee1e712cebf466b995adf4c5307b2bd Date: 2024-05-01T02:08:25.066Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 5.4.0-177-generic

VS Code version: Code 1.89.0 (b58957e67ee1e712cebf466b995adf4c5307b2bd, 2024-05-01T02:08:25.066Z) OS version: Linux x64 5.4.0-177-generic Modes:

System Info
Item Value
CPUs Intel® Core™ i7-8500Y CPU @ 1.50GHz (4 x 2949)
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_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 2, 2, 2
Memory (System) 7.65GB (3.81GB free)
Process Argv –unity-launch --crash-reporter-id e0cccab9-1704-45d5-9a6d-97943ca924da
Screen Reader no
VM 0%
DESKTOP_SESSION xubuntu
XDG_CURRENT_DESKTOP XFCE
XDG_SESSION_DESKTOP xubuntu
XDG_SESSION_TYPE x11
Extensions (10)
Extension Author (truncated) Version
vscode-intelephense-client bme 1.10.4
prettier-vscode esb 10.4.0
copilot Git 1.187.0
copilot-chat Git 0.15.2024043005
todo-tree Gru 0.0.226
remote-ssh ms- 0.110.1
remote-ssh-edit ms- 0.86.0
remote-explorer ms- 0.4.3
material-icon-theme PKi 5.1.0
php-debug xde 1.34.0

(1 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes516:30244333
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
ccp2r3:30993541
dsvsc020:30976470
pythonait:31006305
chatpanelc:31018788
dsvsc021:30996838
jg8ic977:31013176
pythoncenvpt:31022790
dwnewjupytercf:31035177

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 32 (14 by maintainers)

Most upvoted comments

Based on the affected versions, seems like a regression from https://github.com/microsoft/vscode/commit/0da22a226000adc62cf7b8a83b045668fb8a9296

@rzhao271 I updated code the last time to version 1.93.1 on 2024-09-13 via apt. The current .desktop file(s) looks like this:

ls -lah /usr/share/applications/code*

-rwxrwxr-x 1 root root 708 Sep 11 20:06 /usr/share/applications/code.desktop
-rw-rw-r-- 1 root root 312 Sep 11 20:06 /usr/share/applications/code-url-handler.desktop
cat /usr/share/applications/code*

[Desktop Entry]
Name=Visual Studio Code
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=/usr/share/code/code %F
Icon=vscode
Type=Application
StartupNotify=false
StartupWMClass=Code
Categories=TextEditor;Development;IDE;
MimeType=application/x-code-workspace;
Actions=new-empty-window;
Keywords=vscode;

[Desktop Action new-empty-window]
Name=New Empty Window
Name[de]=Neues leeres Fenster
Name[es]=Nueva ventana vacía
Name[fr]=Nouvelle fenêtre vide
Name[it]=Nuova finestra vuota
Name[ja]=新しい空のウィンドウ
Name[ko]=새 빈 창
Name[ru]=Новое пустое окно
Name[zh_CN]=新建空窗口
Name[zh_TW]=開新空視窗
Exec=/usr/share/code/code --new-window %F
Icon=vscode
[Desktop Entry]
Name=Visual Studio Code - URL Handler
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=/usr/share/code/code --open-url %U
Icon=vscode
Type=Application
NoDisplay=true
StartupNotify=true
Categories=Utility;TextEditor;Development;IDE;
MimeType=x-scheme-handler/vscode;
Keywords=vscode;

No --unity-launch flag and the executable points to /usr/share/code/code which is a binary file.


When running code from the terminal, which gives:

which code

/usr/bin/code
ls -lah /usr/bin/code*

lrwxrwxrwx 1 root root  24 Sep 13 09:00 /usr/bin/code -> /usr/share/code/bin/code

This is a symlink and the executable points to /usr/share/code/bin/code which is a shell script.


Running /usr/share/code/code SOMEFILE.txt or /usr/share/code/bin/code SOMEFILE.txt from the terminal opens the file in a new tab as expected.

Double clicking the file opens an empty code window and the process output shows:

ps -fC code

UID          PID    PPID  C STIME TTY          TIME CMD
user      107051       1  1 02:55 ?        00:00:01 /usr/share/code/code --unity-launch /home/user/SOMEFILE.txt

The --unity-launch flag is present there.

As @majid4466 mentioned, the Whisker Menu entry still contains the flag. I boiled it down to be located here:

cat /home/user/.local/share/applications/code.*

[Desktop Entry]
Version=1.1
Type=Application
Name=Visual Studio Code
GenericName=Text Editor
Comment=Code Editing. Redefined.
Icon=com.visualstudio.code
Exec=/usr/share/code/code --unity-launch %F
Actions=new-empty-window;
MimeType=text/plain;inode/directory;application/x-code-workspace;
Categories=Development;IDE;
Keywords=vscode;
StartupWMClass=Code

[Desktop Action new-empty-window]
Name=New Empty Window
Exec=/usr/share/code/code --new-window %F

The ~/.local/share/applications folder “overwrites” the /usr/share/applications folder.

Removing the --unity-launch flag in ~/.local/share/applications/code.desktop solves the problem.

Based on the latest posts here and pointing to a regression from 0da22a2 I found a workaround. I am on an Xubuntu machine with XFCE and Whiskers menu. Here is what I did:

  1. I found the VS code’s icon in Whiskers menu, right clicked it and selected “Edit Application …”
  2. In the “Edit Launcher” window I had this in the “Command” field: /usr/share/code/code --unity-launch %F
  3. I removed the --unity-launch flag and saved.

That was it! The issue gone.

I have the same issue on Gnome Nautilus, double click on the file in the file manager launches a new empty instance of VSCode. I’m using Arch and VSCode is installed through AUR.

Version: 1.89.1 Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685 Date: 2024-05-07T05:16:23.416Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 6.8.9-arch1-2

I can confirm that reverting Code with the “snap revert” command resolved the issue, the current installation details are the following:

Version: 1.88.1 Commit: e170252f762678dec6ca2cc69aba1570769a5d39 Date: 2024-04-10T17:34:12.840Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 6.5.0-28-generic snap