I use wsl in my laptop, it is a debian wsl, in it i have home manager installed.
I wanted to open pdf files with windows default application via xdg-open, for this i was trying to make a desktop file and set it as default but i cant seem to get it to open the files i want
and this is the output i get when i try to open a pdf file via xdg-open
WARNING: You don't seem to have a mime-info database. The shared-mime-info package is available from http://freedesktop.org/ at /usr/bin/mimetype line 175.
No mimeinfo database found
xdg-mime: mimetype argument missing
Try 'xdg-mime --help' for more information.
Error: no "view" mailcap rules found for type "application/pdf"
WARNING: You don't seem to have any mimeinfo.cache files.
Try running the update-desktop-database command. If you
don't have this command you should install the
desktop-file-utils package. This package is available from
http://freedesktop.org/wiki/Software/desktop-file-utils/
WARNING: You don't seem to have a mime-info database. The shared-mime-info package is available from http://freedesktop.org/ at /usr/bin/mimeopen line 129.
No mimeinfo database found
i do have the package update-mime-database so i assume i have the shared-mime-info package installed.
Furthermore after XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default application/pdf I only seem to get nothing:
Checking /home/azevedo/.config/mimeapps.list
Checking /home/azevedo/.local/share/applications/mimeapps.list
Checking /home/azevedo/.local/share/applications/defaults.list and /home/azevedo/.local/share/applications/mimeinfo.cache
Checking /home/azevedo/.local/share/applications/defaults.list and /home/azevedo/.local/share/applications/mimeinfo.cache
Checking /home/azevedo/.nix-profile/share/applications/applications/defaults.list and /home/azevedo/.nix-profile/share/applications/applications/mimeinfo.cache
Checking /home/azevedo/.nix-profile/share/applications/applications/defaults.list and /home/azevedo/.nix-profile/share/applications/applications/mimeinfo.cache
And i should note that the file /home/azevedo/.config/mimeapps.list is generated by home-manager and contains the following:
Following this I tried running XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query filetype some-pdf-file.pdf only to be met with:
Running mimetype --brief --dereference "/home/azevedo/Docs/a.pdf"
WARNING: You don't seem to have a mime-info database. The shared-mime-info package is available from http://freedesktop.org/ at /usr/bin/mimetype line 175.
No mimeinfo database found
I have been thinking about your problem, and I keep coming back to the text of the warning: You don't seem to have a mime-info database. What happens if you install shared-mime-info, just to be safe?
Pretty sure sudo update-mime-database /usr/share/mime is not the right thing to do on nix, but that would typically solve this on other distros.
I installed shared-mime-info package trough home-manager home.packages option, and i ran the command upadte-mime-database but no luck, is still get the exact same error
@Azeved00 I am trying to replicate your issue. I am using NixOS, though, not Debian. But I am using WSL 2.
And, I agree, the behavior of xdg-open is weird. I am not getting the exact same errors and issues as you. But no matter what I do, xdg-open insists on opening a PDF with elinks (which I have installed), even though xdg-mime query filetype and xdg-mime query default application/pdf do, in my case, return the correct values. Go figure.
For an entertaining read/rant on xdg-open, see this thread.
So… might you consider using an xdg-open alternative, like handlr or wsl-open? Both are available in nixpkgs. If I were in your shoes (which I kinda am, using WSL on my laptop at work), I would just use wslview by itself, or look at handlr.
Something else interesting: what happense if you execute the following?
export BROWSER=wslview
Then try xdg-open? I was pleasantly surprised by the results in my setup.
Glad that works for you! I believe there are conditions in which xdg-open does not use xdg-mime, but instead uses file for some reason. Maybe when it is… a file? I need to find where I read that.
I have played with handlr, and really like it. It kinda replaces xdg-open. Let us know if you get a chance to try it.