MIME type associations are not in effect?

gio reports that application/pdf is linked to a bunch of applications:

$ gio mime application/pdf
Default application for “application/pdf”: org.gnome.Evince.desktop
Registered applications:
	org.gnome.Evince.desktop
	chromium-browser.desktop
	com.github.xournalpp.xournalpp.desktop
	draw.desktop
	gimp.desktop
	mcomix.desktop
	org.inkscape.Inkscape.desktop
Recommended applications:
	org.gnome.Evince.desktop
	chromium-browser.desktop
	com.github.xournalpp.xournalpp.desktop
	draw.desktop
	gimp.desktop
	mcomix.desktop
	org.inkscape.Inkscape.desktop

But if I try to open such a file:

$ gio open foo.pdf
gio: file:///home/username/foo.pdf: No application is registered as handling this file

Same with xdg-open:

$ xdg-open foo.pdf
gio: file:///home/username/foo.pdf: No application is registered as handling this file

GNOME Files, on the other hand, has no problems running Evince when opening PDFs.

What’s missing from my setup?

1 Like

Another thing to check is that the correct media type is detected:

$ xdg-mime query filetype 'foo.pdf'
application/pdf

Yep, that prints “application/pdf”. Still no idea why xdg-open seems broken.

Just to be safe, what does gio info foo.pdf say? Though on GNOME, xdg-utils should use that internally.

The main things that affect this is presence of desktop files in applications subdirectory of one of the directories listed in XDG_DATA_DIRS or XDG_DATA_HOME (the latter falls back to ~/.local/share), presence of MIME data in mime subdirectory of directories in those variables, and then $XDG_CONFIG_HOME/mimeapps.list file (XDG_CONFIG_HOME falls back to ~/.config).

$ gio info foo.pdf 
display name: foo.pdf
edit name: foo.pdf
name: foo.pdf
type: regular
size:  43966
uri: file:///home/username/foo.pdf
local path: /home/username/foo.pdf
unix mount: /dev/mapper/vg-home /home ext4 rw,relatime
attributes:
  standard::type: 1
  standard::name: foo.pdf
  standard::display-name: foo.pdf
  standard::edit-name: foo.pdf
  standard::copy-name: foo.pdf
  standard::icon: application-pdf, x-office-document, application-pdf-symbolic, x-office-document-symbolic
  standard::content-type: application/pdf
  standard::fast-content-type: application/pdf
  standard::size: 43966
  standard::allocated-size: 45056
  standard::symbolic-icon: application-pdf-symbolic, x-office-document-symbolic, application-pdf, x-office-document
  etag::value: 1651808717:169382
  id::file: l65027:19609
  id::filesystem: l65027
  access::can-read: TRUE
  access::can-write: TRUE
  access::can-execute: FALSE
  access::can-delete: TRUE
  access::can-trash: TRUE
  access::can-rename: TRUE
  time::modified: 1651808717
  time::modified-usec: 169382
  time::access: 1651808717
  time::access-usec: 168382
  time::changed: 1651808717
  time::changed-usec: 169382
  time::created: 1651808717
  time::created-usec: 168382
  unix::device: 65027
  unix::inode: 19609
  unix::mode: 33188
  unix::nlink: 1
  unix::uid: 1000
  unix::gid: 100
  unix::rdev: 0
  unix::block-size: 4096
  unix::blocks: 88
  owner::user: username
  owner::user-real: 
  owner::group: users