Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Code opens folders instead of the file manager on some Linux distros #114425

Closed
ishfaqfariq opened this issue Jan 15, 2021 · 26 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders linux Issues with VS Code on Linux packaging Issues with the package config or distribution upstream Issue identified as 'upstream' component related (exists outside of VS Code) verified Verification succeeded
Milestone

Comments

@ishfaqfariq
Copy link

I'm using kali linux latest version.And after installing VSC, the drive paths on my desktop are opening in VSC. The paths for drives on my desktop opens just as if its a text file. Its just happing on desktop. I can access my drives from toolbar though. But still its quite strange and uncomfortable. After talking with team, they suggested me to use VSC insider. And due to some reasons, i wasn't able to reply to them for a week. And today i checked and its doing same on both. Kindly Check it out.

Screencast.2021-01-15.21.47.28.mp4
@vscodebot
Copy link

vscodebot bot commented Jan 15, 2021

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@ishfaqfariq
Copy link
Author

@ishfaqfariq
Copy link
Author

In case, if you aren't able to see the recording. kindly check this link out:
https://drive.google.com/file/d/1Lr9rsWXRHYwd_SNdRdcOY8TbLjepQ5Zu/view?usp=sharing
I've recorded the issue in it.

@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities linux Issues with VS Code on Linux labels Jan 18, 2021
@joaomoreno joaomoreno added this to the Backlog milestone Jan 18, 2021
@Tyriar
Copy link
Member

Tyriar commented Jan 19, 2021

Last I looked into this, distros do all sorts of things when you register a mime type handler in a desktop file. Here is the responsible line, but AFAIK this is how we're meant to do it:

MimeType=text/plain;inode/directory;application/x-@@NAME@@-workspace;

@ishfaqfariq
Copy link
Author

I'm not much technical, I'm new to this distro too. Can you please explain it more. How can i fix this issue? Or you guys will fix it in new update ?

@Tyriar
Copy link
Member

Tyriar commented Jan 19, 2021

Ideally an expert who knows about this will show up to tell us what we're doing wrong. Right now we register as a handler of directories with inode/directory above, the question is why are we taking priority over the builtin file manager.

@ishfaqfariq
Copy link
Author

So things are beyond my league. Sorry I wasn't much of a help.

@Tyriar Tyriar changed the title Messes with Drive Paths On Debain Based Kali Linux VS Code opens folders instead of the file manager on some Linux distros Oct 12, 2021
@Tyriar Tyriar assigned rzhao271 and unassigned Tyriar Dec 7, 2022
@rzhao271 rzhao271 added the packaging Issues with the package config or distribution label Dec 7, 2022
@palexdev
Copy link

This must be fixed as a top priority
I can't open folders because VSCode opens instead, this is kinda ridicolous

@rzhao271
Copy link
Contributor

Hi @palexdev, which Linux distro and desktop environment (DE) do you use?

@rzhao271 rzhao271 added the info-needed Issue requires more information from poster label Dec 28, 2022
@palexdev
Copy link

Hi @palexdev, which Linux distro and desktop environment (DE) do you use?

I'm using Garuda Linux (Arch), GNOME edition

@rzhao271
Copy link
Contributor

Did you install the code package using pacman, or did you download it from the website? The Arch code package already removes the inode/directory handler https://github.com/archlinux/svntogit-community/blob/packages/code/trunk/PKGBUILD#L84, so I don't think this issue should occur using that package.

On Ubuntu, when I type xdg-mime query default inode/directory I get nautilus-folder-handler.desktop. I'm wondering whether you can verify and/or reassociate the mime type following https://wiki.archlinux.org/title/XDG_MIME_Applications?

@palexdev
Copy link

palexdev commented Jan 3, 2023

I installed visual-studio-code-bin from Chaotic AUR, version 1.74.2-1

If I execute xdg-mime query default inode/directory the output is code.desktop

@rzhao271 rzhao271 removed the info-needed Issue requires more information from poster label Jan 31, 2023
@schmensch
Copy link

This is incredibly infuriating. Just installing VSCode is enough to make my complete computer almost unusable until I find the right xdg-mime command. Please fix this ASAP!

@RokeJulianLockhart
Copy link

RokeJulianLockhart commented Sep 24, 2023

#114425 (comment)

code-insiders on cpe:/o:opensuse:tumbleweed:20230921 with KDE Plasma 5, using https://en.opensuse.org/Visual_Studio_Code#Install.

It also temporarily removed the file association for file: in https://software.opensuse.org/package/MozillaFirefox for me (though, strangely, it works now).

@TDuffinNTU
Copy link

KDE-Neon 5.27 here. Got this issue using the Snap and Deb versions. Note that the below workaround only works for the Deb installation method, likely because the mimeinfo.cache file I modified is sandboxed under snap (and possibly flatpak too).

Solution (workaround) for me was the following:

  1. Open mimecache.info with your preferred editor
    kate /usr/share/applications/mimeinfo.cache

  2. Move code.desktop to the end of the list of applications under inode/directory:

-- inode/directory=code.desktop;org.kde.dolphin.desktop;org.kde.gwenview.desktop;org.kde.kate.desktop;
++ inode/directory=org.kde.dolphin.desktop;org.kde.gwenview.desktop;org.kde.kate.desktop;code.desktop;
  1. Save the file (NB: You need to open/save the file as root!)

The fix should work immediately.


I'm not too sure who's responsible for fixing this. It seems that this could happen for any app that wants to assign itself as a potential candidate for opening folders. The fact it only happens on certain distros (namely KDE) suggests that KDE parses the mimeinfo.cache file differently to other environments such as GNOME. In which case, I'll open a bug report on their end.

@RokeJulianLockhart
Copy link

The fact it only happens on certain distros (namely KDE) suggests that KDE parses the mimeinfo.cache file differently to other environments such as GNOME. In which case, I'll open a bug report on their end.

Please link the bugs.kde.org bug here when you do, @TDuffinNTU.

@TDuffinNTU
Copy link

TDuffinNTU commented Sep 26, 2023

@RokeJulianLockhart

https://bugs.kde.org/show_bug.cgi?id=474920

Here's the bug I've filed with KDE's xdg-desktop-portal-kde project :)

@TDuffinNTU
Copy link

TDuffinNTU commented Sep 26, 2023

@rzhao271

On Ubuntu, when I type xdg-mime query default inode/directory I get nautilus-folder-handler.desktop. I'm wondering whether you can verify and/or reassociate the mime type following https://wiki.archlinux.org/title/XDG_MIME_Applications?

Ubuntu has a preference of Snap packages over debs (Snap VScode is suggested via the graphical store/CLI but the deb version requires manual installation). In which case, it's likely modifications to mimeinfo.cache are being made within a sandbox (or some other location) over the host location (/usr/share/applications/mimeinfo.cache). This is speculation, since I don't really know how the sandboxing and xdg portals work, but I digress.

That may be why xdg-mime query inode/directory may return Dolphin/Thunarr but in practice VScode still attempts to open when xdg-open is invoked from some other sandboxed apps. I noticed this manifested as "nothing happening" but using journalctl -f I quickly found that xdg portal was simply failing to invoke vscode:

[...] xdg-desktop-por[8898]: Error registering file:///[...] for com.visualstudio.code: GDBus.Error:org.freedesktop.portal.Error.InvalidArgument: Invalid fd passed

Whereas using the deb version, VScode launched when attempting to open Dolphin via the same button on the app I was using.

@Ammar64
Copy link

Ammar64 commented Sep 27, 2023

Ideally an expert who knows about this will show up to tell us what we're doing wrong. Right now we register as a handler of directories with inode/directory above, the question is why are we taking priority over the builtin file manager.

Because this file specify these privileges /usr/share/applications/mimeinfo.cache
open it with VS Code using this command 'code /usr/share/applications/mimeinfo.cache'
press ctrl + f to search
search for directory
you will find this line
image
notice that
inode/directory=code.desktop;org.gnome.Nautilus.desktop;

code.desktop is before org.gnome.Nautilus.desktop that's my file manager on gnome Idk what is it on on kali XFCE
simply edit this line to look like this
inode/directory=org.gnome.Nautilus.desktop;code.desktop;
press ctrl + s to save and click on retry as sudo type your password and done

@rzhao271
Copy link
Contributor

rzhao271 commented Sep 27, 2023

Potential upstream issues:

Also see https://bbs.archlinux.org/viewtopic.php?id=284814, where the suggestion is to add default file associations to mimeapps.list instead.

@rzhao271 rzhao271 added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Sep 27, 2023
@crazyboycjr
Copy link

For those who want to take a look why xdg chooses vscode over your file manager. This command could be useful.

XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default inode/directory

@Pointedstick
Copy link

Hello! I'm a KDE developer. I can confirm that VSCode should be added to the end of the inode/directory= list, not the beginning. The first entry there gets used as the default app for handling that mimetype, and this should always be a file manager, not VSCode. :)

@bzm3r
Copy link

bzm3r commented Nov 13, 2023

@Pointedstick So, is this an issue on VS Code's end (i.e. is VS Code adding itself first)?

@rzhao271
Copy link
Contributor

rzhao271 commented Nov 13, 2023

@bzm3r It's likely not an issue on our end. Here's a link to a previous comment that suggests some other issues that could be happening #114425 (comment).

I'll also have to confirm whether there's any way code can add itself to the end of the list rather than the beginning of the list with the update-desktop-database command.

@Pointedstick
Copy link

It's complicated. There are unfortunately competing standards for how default apps are determined in the Linux world. The problem is that VSCode conforms to none of them.

@ravihlb
Copy link

ravihlb commented Dec 15, 2023

@Ammar64 's solution worked for me, thanks a lot

telamon added a commit to telamon/vscode that referenced this issue Apr 4, 2024
This software is not a plain text editor, and it's definitely not a file manager.
Advertising compatibility with such overrides default OS handlers on many distributions, unnecessarily.
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Apr 17, 2024
@rzhao271 rzhao271 modified the milestones: Backlog, April 2024 Apr 24, 2024
@aeschli aeschli added the verified Verification succeeded label Apr 25, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities insiders-released Patch has been released in VS Code Insiders linux Issues with VS Code on Linux packaging Issues with the package config or distribution upstream Issue identified as 'upstream' component related (exists outside of VS Code) verified Verification succeeded
Projects
None yet
Development

No branches or pull requests