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

VSCode is set as default for 'inode/directory'. This cannot be configured otherwise #259239

Closed
MichaelBrunn3r opened this issue Oct 5, 2023 · 9 comments

Comments

@MichaelBrunn3r
Copy link
Contributor

Describe the bug

VSCode is set as the default application for the mime type inode/directory. This can't be changed.

Steps To Reproduce

Steps to reproduce the behavior:

  • Add vscode, vscode-fhsor vscode.fshto config.environment.systemPackages or user packages
  • Execute xdg-mime query default inode/directory-> code.desktop
  • Set another application as default: xdg-mime default nautilus.desktop inode/directory
  • Alternatively add this to your config:
xdg.mime = {
  enable = true;
  defaultApplications = {
    "inode/directory" = ["nautilus.desktop"];
  };
};
  • Alternatively add this to your config if you are using home-manager:
home-manager.users.<user>.xdg = {
  enable = true;
  mimeApps = {
    enable = true;
    defaultApplications = {
      "inode/directory" = ["nautilus.desktop"];
    };
  };
};
  • Execute xdg-mime query default inode/directory-> Still code.desktop

Expected behavior

xdg-mime default nautilus.desktop inode/directory and the two alternate configurations should change the default application.

Additional context

I used the command XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default inode/directory to find out more about this issue. All files that home-manager or config.xdg.mime configure contain the expected entries:
~/.config/mimeapps.list

[Default Applications]
inode/directory=nautilus.desktop

/etc/xdg/mimeapps.list

[Default Applications]
inode/directory=nautilus.desktop

Here is the full output of running XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default inode/directory:

Checking /home/michael/.config/mimeapps.list
Checking /etc/xdg/mimeapps.list
Checking /home/michael/.local/share/applications/mimeapps.list
Checking /home/michael/.local/share/applications/gnome-defaults.list and /home/michael/.local/share/applications/gnome-mimeinfo.cache
Checking /home/michael/.local/share/applications/defaults.list and /home/michael/.local/share/applications/mimeinfo.cache
Checking /nix/store/icgrfdnwnch379gzl25f5rdwjf4m2cmx-gnome-console-44.0/share/applications/gnome-defaults.list and /nix/store/icgrfdnwnch379gzl25f5rdwjf4m2cmx-gnome-console-44.0/share/applications/gnome-mimeinfo.cache
Checking /nix/store/icgrfdnwnch379gzl25f5rdwjf4m2cmx-gnome-console-44.0/share/applications/defaults.list and /nix/store/icgrfdnwnch379gzl25f5rdwjf4m2cmx-gnome-console-44.0/share/applications/mimeinfo.cache
Checking /nix/store/9r06isigxqfa6b41g2cmci0x5fqxi49p-gsettings-desktop-schemas-44.0/share/gsettings-schemas/gsettings-desktop-schemas-44.0/applications/gnome-defaults.list and /nix/store/9r06isigxqfa6b41g2cmci0x5fqxi49p-gsettings-desktop-schemas-44.0/share/gsettings-schemas/gsettings-desktop-schemas-44.0/applications/gnome-mimeinfo.cache
Checking /nix/store/9r06isigxqfa6b41g2cmci0x5fqxi49p-gsettings-desktop-schemas-44.0/share/gsettings-schemas/gsettings-desktop-schemas-44.0/applications/defaults.list and /nix/store/9r06isigxqfa6b41g2cmci0x5fqxi49p-gsettings-desktop-schemas-44.0/share/gsettings-schemas/gsettings-desktop-schemas-44.0/applications/mimeinfo.cache
Checking /nix/store/s2xm96q0wfvd89ph3fgkvx8v5qd17cb1-gtk4-4.10.3/share/gsettings-schemas/gtk4-4.10.3/applications/gnome-defaults.list and /nix/store/s2xm96q0wfvd89ph3fgkvx8v5qd17cb1-gtk4-4.10.3/share/gsettings-schemas/gtk4-4.10.3/applications/gnome-mimeinfo.cache
Checking /nix/store/s2xm96q0wfvd89ph3fgkvx8v5qd17cb1-gtk4-4.10.3/share/gsettings-schemas/gtk4-4.10.3/applications/defaults.list and /nix/store/s2xm96q0wfvd89ph3fgkvx8v5qd17cb1-gtk4-4.10.3/share/gsettings-schemas/gtk4-4.10.3/applications/mimeinfo.cache
Checking /nix/store/icgrfdnwnch379gzl25f5rdwjf4m2cmx-gnome-console-44.0/share/gsettings-schemas/gnome-console-44.0/applications/gnome-defaults.list and /nix/store/icgrfdnwnch379gzl25f5rdwjf4m2cmx-gnome-console-44.0/share/gsettings-schemas/gnome-console-44.0/applications/gnome-mimeinfo.cache
Checking /nix/store/icgrfdnwnch379gzl25f5rdwjf4m2cmx-gnome-console-44.0/share/gsettings-schemas/gnome-console-44.0/applications/defaults.list and /nix/store/icgrfdnwnch379gzl25f5rdwjf4m2cmx-gnome-console-44.0/share/gsettings-schemas/gnome-console-44.0/applications/mimeinfo.cache
Checking /nix/store/8k5vrqfpqs2zvfq5sgcd9k6aw510qwhq-desktops/share/applications/gnome-defaults.list and /nix/store/8k5vrqfpqs2zvfq5sgcd9k6aw510qwhq-desktops/share/applications/gnome-mimeinfo.cache
Checking /nix/store/8k5vrqfpqs2zvfq5sgcd9k6aw510qwhq-desktops/share/applications/defaults.list and /nix/store/8k5vrqfpqs2zvfq5sgcd9k6aw510qwhq-desktops/share/applications/mimeinfo.cache
Checking /home/michael/.local/share/flatpak/exports/share/applications/gnome-defaults.list and /home/michael/.local/share/flatpak/exports/share/applications/gnome-mimeinfo.cache
Checking /home/michael/.local/share/flatpak/exports/share/applications/defaults.list and /home/michael/.local/share/flatpak/exports/share/applications/mimeinfo.cache
Checking /var/lib/flatpak/exports/share/applications/gnome-defaults.list and /var/lib/flatpak/exports/share/applications/gnome-mimeinfo.cache
Checking /var/lib/flatpak/exports/share/applications/defaults.list and /var/lib/flatpak/exports/share/applications/mimeinfo.cache
Checking /home/michael/.nix-profile/share/applications/gnome-defaults.list and /home/michael/.nix-profile/share/applications/gnome-mimeinfo.cache
Checking /home/michael/.nix-profile/share/applications/defaults.list and /home/michael/.nix-profile/share/applications/mimeinfo.cache
Checking /etc/profiles/per-user/michael/share/applications/gnome-defaults.list and /etc/profiles/per-user/michael/share/applications/gnome-mimeinfo.cache
Checking /etc/profiles/per-user/michael/share/applications/defaults.list and /etc/profiles/per-user/michael/share/applications/mimeinfo.cache
code.desktop

Of the listed files only ~/.config/mimeapps.list, /etc/xdg/mimeapps.list and /etc/profiles/per-user/michael/share/applications/mimeinfo.cache exist.

/etc/profiles/per-user/michael/share/applications/mimeinfo.cache

[MIME Cache]
inode/directory=code.desktop;

This seems to be the culprit. But it is a read-only file, idk how to configure it with Nix.
I also tried everything again with org.gnome.nautilus.desktop and nautilus as the default app, same result.

Notify maintainers

@eadwu @Synthetica9

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
this path will be fetched (0.01 MiB download, 0.05 MiB unpacked):
  /nix/store/vfdg65hiv4bwls48588msw8la7452w2q-stdenv-linux
copying path '/nix/store/vfdg65hiv4bwls48588msw8la7452w2q-stdenv-linux' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.52, NixOS, 23.05 (Stoat), 23.05.20230912.e5f018c`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.15.2`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@AlephNought0
Copy link
Contributor

Did anyone manage to fix this issue? I am having the same problem but with multiple apps and it is annoying. I did manage to fix this once before reinstalling NixOS but I did it by doing random stuff and hoping something might work so I do not even remember what could have fixed it.

@SoSeDiK
Copy link

SoSeDiK commented Jul 24, 2024

Make sure your application is correct (check the .desktop file in store). E.g. for Nautilus it was org.gnome.Nautilus.desktop in my case.

@AlephNought0
Copy link
Contributor

Make sure your application is correct (check the .desktop file in store). E.g. for Nautilus it was org.gnome.Nautilus.desktop in my case.

I can confirm that the desktop file I was using was correct. Despite that the problem still remained. Right now however, the problem got magically fixed and I am not sure how. I was just reinstalling dolphin and kate and some dependencies for them (I do not want to use plasma) and somehow it magically started working. I checked xdg-open and now it only checks for mimelist inside my home directory which I believe is the desired result.

I am not sure if this even fixed it but I guess I will leave it here just in case it really does. I was using a mix of kdePackages and libsForQt5 packages but after I switched everything to libsForQt5 (kdePackages are bugged for me for whatever reason) it started working. Here is the list of the packages.

                libsForQt5.ffmpegthumbs
                libsForQt5.qtwayland
                libsForQt5.qtsvg
                libsForQt5.kiconthemes
                libsForQt5.kdf
                libsForQt5.kio-extras
                libsForQt5.kio-admin
                libsForQt5.plasma-integration
                libsForQt5.kdegraphics-thumbnailers
                libsForQt5.kservice
                libsForQt5.kfind
                libsForQt5.kdbusaddons
                libsForQt5.kfilemetadata
                libsForQt5.kconfig
                libsForQt5.kcoreaddons
                libsForQt5.kguiaddons
                libsForQt5.ki18n
                libsForQt5.kitemviews
                libsForQt5.kwidgetsaddons
                libsForQt5.kwindowsystem
                libsForQt5.kate
                libsForQt5.dolphin
                shared-mime-info

Maybe it was kde packages that interfered with the mime stuff.

@AlephNought0
Copy link
Contributor

I made a mistake in my config and the issue of xdg-open searching many random files came back. I simply had a typo where instead of "firefox.desktop" I put "fifirefox.desktop". Although I had no typos before fixing the issue for the first time, maybe it might help in identifying the core issue.

@eclairevoyant
Copy link
Contributor

eclairevoyant commented Aug 10, 2024

[Removed Associations]
inode/directory=codium.desktop

You're probably looking for something like this, if you're using xdg-open (replace codium with whatever the desktop file is named as in vscode). Anyway this isn't really what I'd call a bug, just need to read https://wiki.archlinux.org/title/XDG_MIME_Applications and https://wiki.archlinux.org/title/Default_applications and configure accordingly.

@AlephNought0
Copy link
Contributor

[Removed Associations]
inode/directory=codium.desktop

You're probably looking for something like this, if you're using xdg-open (replace codium with whatever the desktop file is named as in vscode). Anyway this isn't really what I'd call a bug, just need to read https://wiki.archlinux.org/title/XDG_MIME_Applications and https://wiki.archlinux.org/title/Default_applications and configure accordingly.

This doesn't fix anything. The problem is that when you use specific apps then xdg-open instead of searching for the proper file it goes around everywhere until it finds a cache file with incorrect values. What you suggested in that case won't fix the issue because xdg-open won't even search for the generated mimelist file in the first place.

When functionality breaks because of something and the only way to fix it is by removing the culprit then I believe that it indeed is a bug.

@eclairevoyant
Copy link
Contributor

Considering I use vscodium (a vscode fork, which has the same behaviour in this scenario) daily without having such issues, as I set my default handler for directories to be Thunar, and do so without changing the packaging for vscodium.

$ xdg-mime query default inode/directory
thunar.desktop

Misconfiguration is user error, and not a bug.

@AlephNought0
Copy link
Contributor

Considering I use vscodium (a vscode fork, which has the same behaviour in this scenario) daily without having such issues, as I set my default handler for directories to be Thunar, and do so without changing the packaging for vscodium.

$ xdg-mime query default inode/directory
thunar.desktop

Misconfiguration is user error, and not a bug.

The problem happened when I installed the application without changing anything. I used vscodium-fhs so maybe this package specifically ruins something but I don't use it anymore. I really don't see how installing an application and doing nothing else is user error. I can test that specific package once again when I come home.

Just like mentioned before, the issue is that xdg-open does not search for the correct file when using a specific app, in this case it was vscode for Michael and vscodium-fhs for me.

Also, I don't think it's wise to change default application imperatively when it's already being done declaratively through mimeApps option.

@eclairevoyant
Copy link
Contributor

eclairevoyant commented Aug 10, 2024

The problem happened when I installed the application without changing anything.

If you have multiple apps that can handle a given MIME type, you'd have to configure which one you prefer, that's a given. Instructions on how to do so were provided above. Otherwise the system is just guessing which one you want, seems like xdg-* uses alphabetical order by default.

I don't think it's wise to change default application imperatively

The config mentioned above is the desired target config, so you can use whichever module (NixOS or HM or whatever) to achieve that target config. MichaelBrunn3r showed how two examples of how to do so in their original post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants