Firefox from Snap or .deb?

Canonical is pushing Snap package management quite heavily in Ubuntu, and true, it has its merits, but it also comes with many issues. For me, the biggest problem has been that Firefox runs slowly, especially during startup.

I decided to try switching back to Firefox installed from a .deb package. After a quick Google search, the process seemed fairly straightforward—and it was, although almost all the guides missed one crucial detail.

How do you know if a package was installed via Snap or apt? Well, for example, by using Snap’s own commands. The snap list command lists everything installed through Snap.

Bash

snap list

I followed the instructions on the AskUbuntu site. In short, the process goes like this: first, add Mozilla’s own repository to apt, set it as the primary priority, remove the Snap version, install the apt version, and configure the settings so that updates won’t reinstall the Snap package.

Following these steps replaces the Snap-installed version of Firefox on your machine with the latest stable Firefox directly from Mozilla’s maintained source.

First, let’s install Mozilla’s official Firefox PPA. It’s also a good idea to update the apt database.

Bash

sudo add-apt-repository ppa:mozillateam/ppa
sudo apt update

Next, set the apt version as the primary choice by creating the file /etc/apt/preferences.d/mozilla-firefox using the tee command and filling in the appropriate details. Apt’s preferences.d is a directory where you can tell apt how to handle specific packages if desired. The following block needs to be copied completely into the command line all at once (or you can use nano/vim/emacs to create the file containing the text between the ' marks).

Bash

echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001

Package: firefox
Pin: version 1:1snap*
Pin-Priority: -1
' | sudo tee /etc/apt/preferences.d/mozilla-firefox

Next, remove the Snap version. This took a surprisingly long time, at least for me. Apparently, Snap made a backup of the Firefox installation before removing it.

Bash

sudo snap remove firefox

If Snap complains that it cannot remove everything, try deleting the AppArmor firefox files, disable hunspell, and try removing the Snap version again.

Bash

sudo rm /etc/apparmor.d/usr.bin.firefox 
sudo rm /etc/apparmor.d/local/usr.bin.firefox
sudo systemctl stop var-snap-firefox-common-host\x2dhunspell.mount
sudo systemctl disable var-snap-firefox-common-host\x2dhunspell.mount

After removing the Snap version, Firefox should install normally via the standard apt install command.

Bash

sudo apt install firefox

Finally, configure automatic updates so they don’t accidentally reinstall the Snap version.

Bash

echo 'Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";' | sudo tee /etc/apt/apt.conf.d/51unattended-upgrades-firefox

At this point, Firefox wouldn’t start for me because AppArmor was blocking it. The error message at this stage wasn’t very clear, at least to me… Deep in the web, I found these commands to get Firefox working:

Bash

sudo ln -s /etc/apparmor.d/usr.bin.firefox /etc/apparmor.d/disable/
sudo systemctl restart apparmor

If you ever feel like returning to the Snap version, you can do so by removing the files and software sources you created, and then reinstalling Firefox via Snap.

Bash

sudo add-apt-repository -r ppa:mozillateam/ppa
sudo rm -rf /etc/apt/preferences.d/mozilla-firefox
sudo apt remove firefox && sudo snap install firefox

I’ve been using the apt/.deb version for a little while now and I am mostly satisfied. Firefox launches nicely and most of the time works well—actually, overall it’s faster than when installed from the Snap package—but occasionally it freezes completely. The freezes feel as if the web pages themselves across all tabs stop responding to the mouse; everything else works completely fine (you can switch tabs, the Firefox menus work, videos on the pages keep playing), but it looks like all clicks on the pages get stuck somewhere for a moment and then go through all at once in a burst. I don’t know what causes that, but I’ll look into it. On average, though, it works noticeably faster.

PS. I also tested how Gemini can make thumbnail for this post. I used next prompt

Can you make me a thumbnail picture for a blog post where I talk how I changed firefox from away linux snap package and installed it from .deb package. 

With typos and all….

Author: Jra78

Leave a Reply

Your email address will not be published. Required fields are marked *