Ubuntu – `xdg-open` does not open files in the preferred applicaton

20.04mime-typenautilusxdg-open

xdg-open does not work as expected. It opens most my files in browser, directories in my code editor(VS code) and plain text files using less. It also throws this error message,

$ xdg-open $HOME
xdg-mime: mimetype argument missing
Try 'xdg-mime --help' for more information.

then it opens the folder in my code editor. Whereas,

$ xdg-mime query default inode/directory
org.gnome.Nautilus.desktop

the default file manager application is Nautilus. How do I fix this?

Best Answer

The following answer suggests that Gnome uses gvfs-open in the background.

https://unix.stackexchange.com/a/144048/421466

gvfs-open has been deprecated and the new command is gio open.

$ gio open
libffi.so.6: cannot open shared object file: No such file or directory

Running gio open threw this error. This error was due to python looking for libffi6.so file which wasn't present in my environment. I am using miniconda and there are other people as well who are facing this issue. Most of the answers suggests to create a symlink for libffi6.so or reinstall python,

https://github.com/conda/conda/issues/9957

https://stackoverflow.com/q/61875869/11701676

But simply installing libffi, using conda fixed the issue.

conda install libffi

Related Question