I have never had issues with opening pdf files until recently. Then, I wanted to readup on the xcolor package for TeX and entered the following command:
texdoc xcolor
This has always worked, opening the documentation in my preferred pdf viewer, qpdfview.
But now, it tries to open it with qpdfview, but qpdfview displays an error:
Could not open '/usr/share/texlive/texmf-dist/doc/latex/xcolor/xcolor.pdf'.
And at the terminal, I get the following error message:
Unknown MIME type: ""
"Could not match file type of '/usr/share/texlive/texmf-dist/doc/latex/xcolor/xcolor.pdf'!"
I am running the i3 tiling window manager under Ubuntu 21.04 and my $XDG_CURRENT_DESKTOP and $DESKTOP_SESSION are set to 'i3'.
So, on a known good pdf file, I entered:
$ mimetype TrigLocal.pdf
TrigLocal.pdf: text/plain
Though,
$ file --mime-type
application/pdf
Correct.
So, I tried
$ xdg-open TrigLocal.pdf
gio: file:///home/ded/TeXexamples/TrigLocal.pdf: No application is registered as handling this file
OK, so maybe gio is not set properly:
$ gio mime TrigLocal.pdf
No default applications for “TrigLocal.pdf”
I tried setting the handler with
$ xdg-mime default qpdfview.desktop application/pdf
But when I query it:
$ xdg-mime query default application/pdf
qpdfview-chromium.desktop
That's a variant, but one I did not set. In any event, it has no effect on xdg-open:
$ xdg-open TrigLocal.pdf
gio: file:///home/ded/TeXexamples/TrigLocal.pdf: No application is registered as handling this file
I am at a loss as to what is going wrong, and I can find no clear guidance anywhere, at least none that works.
The whole ecosystem of associating file types with handlers under ubuntu mystifies me, so I would appreciate a nice overview tutorial that explains the relationships among:
mime type
xdg-open
gio
and anything else relevant to helping me fix non-Gnome, non-KDE my system.
Update
At @steeldriver's suggestion, I ran:
$ mimetype --debug TrigLocal.pdf
> Data dirs are: /home/ded/.local/share, /var/lib/flatpak/exports/share /home/ded/.local/share /flatpak/exports/share
> Checking inode type
> Checking globs for basename 'TrigLocal.pdf'
> Checking for extension '.pdf'
> Checking globs for basename 'triglocal.pdf'
> Checking for extension '.pdf'
> File exists, trying default method
TrigLocal.pdf: text/plain
I see nothing interesting in ~/.local/share, but I do see this:
$ cat ~/.local/share/applications/mimeapps.list
[Default Applications]
application/pdf=qpdfview.desktop
application/html=google-chrome.desktop
text/html=google-chrome.desktop
x-scheme-handler/http=google-chrome.desktop
x-scheme-handler/https=google-chrome.desktop
x-scheme-handler/about=google-chrome.desktop
x-scheme-handler/unknown=google-chrome.desktop
[Added Associations]
application/pdf=evince.desktop;zathura-pdf-poppler.desktop;