Fix Flatpak browser not opening links in Ubuntu

TL, DR

Sometimes Ubuntu stages a coup, setting the Snap internet browser as default. This may break your setup if you actually instralled your browser using Flatpak. Here a few steps to fix this issue.

Flatpak vs. Snap

Ubuntu has a strong preference for Snaps…but maybe you don’t necessarily agree with this and you prefer to have your browser installed via Flatpak. Generally it’s going to work well, but from time to time Ubuntu may stage a coup and suddenly you may not be able to open links from other applications in your Flatpak browser.

Here I list some steps you may check to fix this issue and live happily with your Flatpak software.

Conflicting settings

So, after the last update you find out you are no longer able to click on links in other applications, for instance Thunderbird, and open a webpage in your favorite browser installed via Flatpak, for instance Firefox.

After scratching your head a few times, rebooting, and staring at the same issue, you’ll start searching for root causes and solutions. Looking at this Github issue, I checked from the terminal what may happen if I tried to open a link as if it was clicked on Thunderbird:

flatpak run --command=/usr/bin/xdg-open org.mozilla.Thunderbird http://randomds.com/

Nothing happened, and the error message told me that Firefox was not installed…and suggested me to install the Snap version. However, I already had Firefox installed as Flatpak and I had no intention to change. Same result for the command:

xdg-open https://randomds.com

I could see some interaction, but ending in nothing….

Looking at xdg-settings, it actually seemed that my Flatpak Firefox was the one supposed to open links. The command I entered on the terminal – following this Stack Exchange answer – to check was:

xdg-settings get default-web-browser

And the return value:

org.mozilla.firefox.desktop

However, following the same post, I also checked the xdg-mime preferences…and I finally found the culprit! Opening the file ~/.config/mimeapp.list clearly showed that – for reason unknown to me – Ubuntu decided to set as default the Snap version of Firefox.

In order to fix the situation, i followed this Stack Exchange answer (on the same issue referenced above) and entered the following command:

xdg-mime default org.mozilla.firefox.desktop x-scheme-handler/https x-scheme-handler/http             

I then opened the ~/.config/mimeapp.list file, and replaced the Snap version of Firefox in the residual places where it was still present with the Flatpak one.

Finally done, Snap coup reversed and I can continue to happily use my Flatpak software!

Related links

  • Github issue on xdg-open defaults link
  • Stack Exchange answer on xdg-settings link
  • Stack Exchange answer on xdg-mime link

Do you like our content? Check more of our posts in our blog!