Celeb Glow
updates | March 17, 2026

mimetype not identifying pdf files: mime hell

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;
2

1 Answer

I found the problem. Running mimetype --debug gave a hint, but I wasn't seeing it. (Thanks @steeldriver) I tried the same command as root on the same file, and it gave the correct answer.

It turned out that, for some reason, a setting for the environment variable XDG_DATA_DIRS got into my shell config file, and it excluded the default directories.

According to the XDG Specification, it is set to "/usr/local/share:/usr/share" by default, and my setting was overriding these, so the default mime database at /usr/share/mime/freedesktop.org.xml was not getting read into the mime detection system.

Since the errant setting added some flatpak-related directories, I must have added the setting in connection with trying out flatpaks, but I don't remeber doing any such thing, so perhaps the setting was added to my config.fish file behind my back.

Anyway, I hope this helps someone in the future.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy