Skip to content

Instantly share code, notes, and snippets.

@jfeilbach
Last active November 7, 2024 21:15
Show Gist options
  • Save jfeilbach/78d0ef94190fb07dee9ebfc34094702f to your computer and use it in GitHub Desktop.
Save jfeilbach/78d0ef94190fb07dee9ebfc34094702f to your computer and use it in GitHub Desktop.
Ubuntu 24.04 remove Firefox snap and install .deb version

Ubuntu 24.04 Firefox snap replacement

I need a proper Firefox installation and not the snap version. The snap version does not work properly with Smart Cards. Although it seems to be possible to get it to work with smart cards it is extremely difficult and I don't care to try and make it work. This is not a tutorial on how to get your PIV or CAC to work. Also snaps suck. Canonical will heopfully abandon snaps in the future.

Remove Snap Firefox

sudo snap disable firefox
sudo snap remove --purge firefox
error: cannot perform the following tasks:
- Remove data for snap "firefox" (1943) (unlinkat /var/snap/firefox/common/host-hunspell/en_ZA.dic: read-only file system)

If you get this error verify that /var/snap/firefox/common/host-hunspell is mounted as an ext4 file system using lsblk -fe7 -o+ro

sudo systemctl stop var-snap-firefox-common-host\\x2dhunspell.mount
sudo systemctl disable var-snap-firefox-common-host\\x2dhunspell.mount 
Removed /etc/systemd/system/default.target.wants/var-snap-firefox-common-host\x2dhunspell.mount.
Removed /etc/systemd/system/multi-user.target.wants/var-snap-firefox-common-host\x2dhunspell.mount.

If this fails you might be able to do this...

sudo umount /var/snap/firefox/common/host-hunspell
sudo snap disable firefox
sudo snap remove --purge firefox

You will probably have leftover files in /var/lib/snapd/seed/snaps from the default Firefox install. You can manually remove them. I don't think there is a snap comand that will remove just the Firfox files. Be careful deleting stuff in this directory especially if you are stil using other snaps besides Firefox. You've been warned.

Block future snap Firefox installs

sudo vim /etc/apt/preferences.d/firefox-no-snap 
Package: firefox*
Pin: release o=Ubuntu*
Pin-Priority: -1

Install Firefox .deb package for Debian-based distributions

To install the .deb package through the APT repository, do the following: Create a directory to store APT repository keys if it doesn't exist:

sudo install -d -m 0755 /etc/apt/keyrings

Import the Mozilla APT repository signing key:

wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null

If you do not have wget installed, you can install it with: sudo apt-get install wget

The fingerprint should be 35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3. You may check it with the following command:

gpg -n -q --import --import-options import-show /etc/apt/keyrings/packages.mozilla.org.asc | awk '/pub/{getline; gsub(/^ +| +$/,""); if($0 == "35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3") print "\nThe key fingerprint matches ("$0").\n"; else print "\nVerification failed: the fingerprint ("$0") does not match the expected one.\n"}'

Next, add the Mozilla APT repository to your sources list:

echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | sudo tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null

Configure APT to prioritize packages from the Mozilla repository:

echo '
Package: *
Pin: origin packages.mozilla.org
Pin-Priority: 1000
' | sudo tee /etc/apt/preferences.d/mozilla

Update your package list and install the Firefox .deb package:

sudo apt-get update && sudo apt-get install firefox

Taken from https://support.mozilla.org/en-US/kb/install-firefox-linux#w_install-firefox-deb-package-for-debian-based-distributions On this page there are also instructions for installing Firefox from Mozilla builds.

Migrate profile

If you have been using Firefox snap version and would like to keep data in your user profile you can follow these steps. If you have never used snap Firefox on your install then you can skip this. You will need to have used the snap Firefox at least once for a Firefox user profile to have been created.

mkdir -p ~/.mozilla/firefox/ && cp -a ~/snap/firefox/common/.mozilla/firefox/* ~/.mozilla/firefox/

Optional. Disable unattended upgrades.

You may want to perform this step because this service might bring back the snap version of Firefox. Thanks Ubuntu.

sudo systemctl status unattended-upgrades
sudo systemctl disable --now unattended-upgrades
sudo systemctl status unattended-upgrades

In file /etc/apt/apt.conf.d/20auto-upgrades

Change from enabled APT fucntions to disabled:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

after it shoud look like this:

APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment