33

I am wondering whether or not there is a way to completely remove Snap from Ubuntu 21.10 (Impish Indri) without losing the ability to install Ubuntu's default browser Firefox.

When I just recently updated to the newest Ubuntu release I realized that the installer programmatically reinstalled Snap, although I had manually removed it before. Additionally the installer removed Firefox, which was installed via the repositories, and reinstalled it via snap.

As I don't want snap to be installed on my machines for various reasons, my question is: Is there a safe way to remove it, and to get the Firefox DEB back to the sources?

Is there a PPA? Could I use a source of an Ubuntu flavor additionally, which didn't remove the Firefox Deb from its sources?

user5950
  • 6,186
  • 7
    FYI: Mozilla (not Canonical, not Ubuntu) is driving the Firefox transition from Deb to Snap. When complete in six months, it's possible that no paid staff will maintain Firefox debs anymore. If you want Firefox debs longer than that, time to start marshalling volunteers to learn and take over that work. – user535733 Oct 14 '21 at 10:51
  • 4
    @user535733 the deb is still in the official repo, and if it remains there for 22.04 then Canonical will support it for at least another five years, – OrangeDog Oct 15 '21 at 07:41
  • 2
    Wait... How will non-ubuntu based distros get firefox if they won't have snap? – Vanity Slug - codidact.com Oct 15 '21 at 16:03
  • 2
    Are you sure, you need it as .deb package? You can get tar.gz files for running Firefox from the Mozilla Server. You can just unpack them and they even have the update mechanism that Firefox is using on Windows. – allo Oct 15 '21 at 16:25
  • 1
    @wha7ever Debian still has deb package for Chromium, so no problem for it to have Firefox. Moreover, Mozilla still continues to provide distro-agnostic binary packages in addition to source code. – Ruslan Oct 15 '21 at 21:04
  • 1
    @Ruslan Thank you. I thought Canonical won't provide anything other than snap for Linux distros. Glad it's not the case. – Vanity Slug - codidact.com Oct 18 '21 at 14:24
  • Not only that, it changes the default browser from Firefox to Chromium. – Kingsley Oct 21 '21 at 20:34
  • According to what I have heard, and experianced, is that the mozilla.deb in Ubuntu repository install snap version. So yes, sad to say that Ubuntu forcing snap on us. BUT, there are a PPA that is handled by Mozilla that have a .deb package, as @Piotr Henryk Dabrowski wrote. Just purge and remove the standard Ubuntu deb and snap, and then add the PPA from Mozilla and install from there. You need to do some additions to upgrade from the Mozilla and not the Ubuntu package. – Anders Apr 24 '22 at 18:39

2 Answers2

35

You can combine two measures.

Start by removing Snap package of Firefox by snap remove firefox --purge.

Then follow the steps:

  1. prevent Snap installation by purging and pinning it with negative priority:

    sudo apt-get autopurge snapd
    

    cat <<EOF | sudo tee /etc/apt/preferences.d/nosnap.pref

    To prevent repository packages from triggering the installation of Snap,

    this file forbids snapd from being installed by APT.

    For more information: https://linuxmint-user-guide.readthedocs.io/en/latest/snap.html

    Package: snapd Pin: release a=* Pin-Priority: -10 EOF

  2. Then install Firefox from

    • official repositories as simple as

      sudo apt-get install firefox
      

      Update april 2022: This option is not anymore applicable in Ubuntu 22.04 and up. Installing the .deb package causes installation of the snap version.

    • some third-party (but trusted) repositories

      a. deb-packaged Firefox from UbuntuZilla - regular or ESR
      Add UbuntuZilla repository with its signing key by

      echo "deb http://downloads.sourceforge.net/project/ubuntuzilla/mozilla/apt all main" | sudo tee -a /etc/apt/sources.list.d/ubuntuzilla.list > /dev/null
      sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2667CA5C
      sudo apt-get update
      sudo apt-get install firefox-mozilla-build
      

      Note: if one needs ESR version - then replace last command with sudo apt-get install firefox-esr-mozilla-build.

      Removal is possible by the following commands:

      sudo rm /etc/apt/sources.list.d/ubuntuzilla.list
      sudo apt-get autoremove --purge '*firefox*'
      sudo apt-get update
      

      b. deb packaged Firefox ESR version from Mozilla Team PPA

      To get Firefox ESR version installed from Mozilla Team PPA use commands below:

      sudo add-apt-repository ppa:mozillateam/ppa
      sudo apt-get update
      sudo apt-get install firefox-esr
      

      Additional locales may be installed by using packages like firefox-esr-locale-it (example for Italian).

      To remove deb-packaged Firefox one can use commands like:

      sudo apt-get install ppa-purge
      sudo ppa-purge ppa:mozillateam/ppa
      sudo apt-get autoremove --purge
      
    • Locally extracted Firefox archive

      If one needs to download and install Firefox to the home folder, then it is possible in the following way:

      mkdir ~/Software ~/bin
      cd ~/Software
      wget -c http://ftp.mozilla.org/pub/firefox/releases/93.0/linux-x86_64/en-US/firefox-93.0.tar.bz2
      tar -xf firefox-93.0.tar.bz2
      ln -sf /home/$USER/Software/firefox/firefox ~/bin/firefox
      

      create desktop-file with long command below

      mkdir -p ~/.local/share/applications/ cat <<EOF > ~/.local/share/applications/firefox-user.desktop #!/usr/bin/env xdg-open [Desktop Entry] Encoding=UTF-8 Name=Firefox (local) GenericName=Browser Comment=Web Browser Exec=firefox %u Icon=/home/$USER/Software/firefox/browser/chrome/icons/default/default48.png Terminal=false X-MultipleArgs=false StartupWMClass=Firefox Type=Application Categories=Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall; EOF

      update-menus

      then logout and login back.

      To remove such local installation use commands below:

      rm -rf ~/Software/firefox
      rm -v ~/.local/share/applications/firefox-user.desktop
      rm -v ~/bin/firefox
      update-menus
      

Discussion and notes:

My personal choice will be one of deb-based.
I would prefer ESR (2b) to get my Firefox behavior stable as it is needed for enterprise level application.

vanadium
  • 88,010
N0rbert
  • 99,918
  • 2
    In future (22.04 onward) we can use Linux Mint's repository to get firefox, as Ubuntu will most likely remove the apt firefox from repositories, just like chromium. – Archisman Panigrahi Jan 12 '22 at 14:12
  • If Mint doesn't compile it, I'd switch to flatpak. It's what snap should have been. And Firefox in Flathub is maintained by Mozilla. – KalEl Feb 28 '22 at 09:26
  • I went for solution 2a (Firefox from PPA) and then 2b (Firefox ESR from PPA) after finding out that in jammy (22.04 LTS) the snap transition package firefox (which I don't want) always has a higher version than the regular Debian package firefox from the PPA (which I want). As a result after blocking the installation of snapd, apt will be unable to update the package firefox. apt tries to go for the most recent version, finds out that it depends on snapd and gives up. The workaround is to use firefox-esr and firefox-esr-locale-fr (for French). – Stéphane Tréboux Apr 22 '22 at 06:51
  • I will use 2b, as that is a PPA, and maintained by Mozilla, and I like to tell Mozilla that it is great that they make a .deb, when Ubuntu doesn't.

    And yeas, I am fine with snap, flatpak etc, as long as it isn't used like Ubuntu does. Those are bloat ware, compared to .deb.

    – Anders Apr 24 '22 at 18:58
  • And I will lower the priority of Ubuntu Firefox package so that doesn't get installed.

    See https://ubuntuhandbook.org/index.php/2022/04/install-firefox-deb-ubuntu-22-04/ or https://balintreczey.hu/blog/firefox-on-ubuntu-22-04-from-deb-not-from-snap/

    – Anders Apr 24 '22 at 19:02
  • Thanks for the links, I just realized that the snap transition Firefox package can be set to a lower priority in apt which should allow updates from the PPA. I will try that then... – Stéphane Tréboux Apr 25 '22 at 02:37
  • I know it sounds obvious, but executing the commands above will not only remove the snap package and different versions but also the user data around it. Learned that the hard way and lost all my bookmarks. By contrast, removing packages with APT does not purge user data. https://snapcraft.io/blog/hey-snap-wheres-my-data – jflaflamme Aug 18 '22 at 08:14
1

You can download the latest official .deb builds for Ubuntu 22.04 LTS (Jammy) here: https://launchpad.net/~phd/+archive/ubuntu/firefox/

This is a PPA repository with official Ubuntu packages released originally for Ubuntu 20.04 LTS (Focal) and updated automatically as soon as a new version is released.

Remember to backup your ~/.mozilla directory (or the snap equivalent).