59

As far as I see in the ongoing development for 22.04 Jammy, Firefox is a Snap package. The related Deb package in apt is just a shortcut/link to the that snap version.

I prefer my installation not to be from snap packages, since I find them too much 'Ubuntu-specific'.

Are there alternative ways to install Firefox on Jammy?
My favourite option would be an Apt repository or PPA. I will test the Flatpak version with my test virtual machine in the meantime.

0

8 Answers 8

65

The other answer by Organic Marble is for Firefox-ESR, and the answer by eddygeek is for the beta version.

This answer is for the latest stable version of Firefox. You can use the Firefox PPA maintained by Mozilla team.

sudo add-apt-repository ppa:mozillateam/ppa

Then, copy and paste the following code in a terminal in one go (don't copy-paste line by line) to prioritize the apt version of firefox over the snap version.

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

Package: firefox
Pin: version 1:1snap1-0ubuntu2
Pin-Priority: -1
' | sudo tee /etc/apt/preferences.d/mozilla-firefox

Next, remove the snap version of firefox

sudo snap remove firefox

Install Firefox with apt.

sudo apt install firefox

To ensure that unattended upgrades do not reinstall the snap version of Firefox, enter the following command. Alternatively, you can turn off unattended upgrades.

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

To undo these changes

  1. Remove the firefox PPA.
sudo add-apt-repository -r ppa:mozillateam/ppa
  1. Remove the apt pin.
sudo rm -rf /etc/apt/preferences.d/mozilla-firefox
  1. Remove the apt version and reinstall snap.
sudo apt remove firefox && sudo snap install firefox

Source: OMG Ubuntu

3
  • 5
    Unattended upgrades may reinstall the snap version if unconfigured. See here
    – mook765
    May 1 at 16:53
  • 13
    It is stupid that Ubuntu thinks that the version in snap is newer than the one from the actual repository. This answer makes sense to block Ubuntu from installing the snap version but it really seems like a pain that you have to add the pinning to block it now where in the past you did not. Thanks for a great answer! +1
    – Terrance
    May 1 at 17:33
  • 1
    Thanks! This is helpful. As a developer, I won't tolerate curl localhost:3000/ working fine, but the browser barfing some BS error at me on that same URL due to Snap shenanigans.
    – ulidtko
    Oct 14 at 10:26
4

The transition of Firefox from Deb to Snap was announced in September 2021. See https://discourse.ubuntu.com/t/feature-freeze-exception-seeding-the-official-firefox-snap-in-ubuntu-desktop/24210/199 for complete discussion.

This is the result of cooperation and collaboration between the Desktop and Snap teams at Canonical and Mozilla developers, and is the first step towards a deb-to-snap transition that will take place during the 22.04 development cycle.

Translation: The shift of Firefox from Deb to Snap is a Mozilla-driven decision. The Ubuntu teams are trying to make the transition as painless as possible for most folks.

A lot of volunteers have been testing the Firefox Snap, discovering/filing/fixing bugs for the entire 21.10 cycle to sand down the rough edges and document the corner-cases. (It's been my daily driver for five months)

When the transition is complete, you will have four options:

  1. Use the Snap. The Snap comes from Mozilla upstream, and is designed to be cross-distro and cross-platform. You should not find it "Ubuntu-specific." The Firefox Snap will be included in stock installs of Ubuntu Desktop.

  2. Download the binary from Mozilla upstream. This requires knowledge of how to install and uninstall without a package manager. It's the same binary used in the Snap.

  3. If you still want to use deb packages that are in the Ubuntu Repositories, then join Debian and help the volunteer packagers who work Firefox. It's a complex beast to packages as a deb (which is why Mozilla is unenthusiatic about continuing the effort) but the community --with enough volunteers-- is capable of great things.

  4. The Ubuntu Mozillateam PPA currently offers Firefox-beta and Firefox-ESR deb packages. These are generally high-quality packages, and also depend upon enough volunteer participation to maintain that quality.

  5. Flatpak and other add-on package managers.

6
  • 6
    Both Flatpak or Snap have the same problem. Both are methods of packaging something "non-native" to the system that brings a lot of environment/dependencies/etc. with it. While for some "standalone" applications this is OK, such an important piece of system as a default web browser should be closely integrated with the system, which means it should be a .deb package. Use of Debian .deb package seems to be the only viable way.
    – raj
    Mar 26 at 15:23
  • 2
    @raj well, it's not going to be a .deb package anymore, like it or not, without a lot more volunteer participation.
    – user535733
    Mar 26 at 18:02
  • 2
    Somebody will provide PPA with firefox.deb soon enough Mar 31 at 21:03
  • 5
    The Mozilla Team PPA has already made the package (along with ESR & thunderbird). The maintainer of Ubuntu's own Firefox package is the team member. launchpad.net/~mozillateam/+archive/ubuntu/ppa. And there's a step by step guide to add the PPA and set priority.
    – Nim
    Apr 5 at 15:43
  • 5
    This bug bugzilla.mozilla.org/show_bug.cgi?id=1661935 (Snap does not support NativeMessaging) makes the snap version too limited for now (eg. browserpass extension, kde plasma integration, gnome extensions integration, etc...). It is a real regression, and I'm not sure the proposed solution will be ready soon...
    – alci
    Apr 6 at 8:06
3

You can install the official Firefox ESR (Extended Support Release) version via .deb from the Mozilla ppa

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

More information is available here: https://ubuntuhandbook.org/index.php/2022/03/install-firefox-esr-ubuntu/

1

You can install the latest official .deb builds working with 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.

1

I found the following workaround to get a deb-based firefox from the firefox-next ppa.

Warning: It is the beta version!

Because the package name is also firefox, we need to blacklist the dummy snap shortcut package which has version 1:1snap1-0ubuntu2

sudo apt remove firefox
echo "
Package: firefox
Pin: version 1:1snap1-0ubuntu2
Pin-Priority: 99
" | sudo tee /etc/apt/preferences
sudo add-apt-repository ppa:mozillateam/firefox-next
sudo apt install firefox

Here is a variant of the add-apt-repository step, that still respects the new package signing requirements - it works with both ppa (main release) and firefox-next (beta) repositories:

sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --no-default-keyring --keyring /usr/share/keyrings/firefox.gpg --recv-keys 9BDB3D89CE49EC21
echo 'deb [signed-by=/usr/share/keyrings/firefox.gpg]  https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu jammy main 
' | sudo tee /etc/apt/sources.list.d/firefox.list

(This was useful for me because under pre-release of KDE Neon 22.04, add-apt-repository currently returns aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Neon/jammy)

1

As mentioned before

Remove snap version of the firefox

sudo snap remove firefox

Add mozillateam repository

sudo add-apt-repository ppa:mozillateam/ppa

Unattended updates

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

If you don't want to update all packages from LP-PPA-mozillateam then i would do following:

echo '
Package: firefox
Pin: version 1:1snap1-0ubuntu2
Pin-Priority: 99

Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 99

Package: firefox*
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
' | sudo tee /etc/apt/preferences.d/mozilla-firefox

This makes only firefox package updated from LP-PPA-mozillateam, and not others. Also reduce priority of the firefox snap version.

And now you are ready to install firefox

sudo apt install firefox
0

The switch from a snap Firefox installation to a ppa and apt installation is is automated here, with an attempt at a bit more control and documentation than the effective and compact script by Archisman Panigrahi. Perhaps someone likes it:

#!/bin/bash
# This script verifies Firefox is installed in the right way. Firefox is used
# to set the GitHub SSH keys and GitHub personal access tokens automatically.
# And to control a Firefox browser, it needs to be installed using apt instead
# of snap. https://stackoverflow.com/questions/72405117
# https://www.omgubuntu.co.uk/2022/04/how-to-install-firefox-deb-apt-ubuntu-22-04
# https://askubuntu.com/questions/1399383/

# Run with:
# bash -c "src/prerequisites/firefox_version.sh"

command_output_contains(){
    local substring="$1"
    shift
    local command_output="$@"
    if grep -q "$substring" <<< "$command_output"; then
        echo "FOUND"
    else
        echo "NOTFOUND"
    fi
}

#######################################
# Checks if firefox is installed using snap or not.
# Locals:
#  respones_lines
#  found_firefox
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If command was evaluated successfully.
# Outputs:
#  FOUND if firefox is installed using snap.
#  NOTFOUND if firefox is not installed using snap.
#######################################
firefox_via_snap(){
    local respons_lines="$(snap list)"
    local found_firefox=$(command_output_contains "firefox" "${respons_lines}")
    echo $found_firefox
}

#######################################
# Checks if firefox is installed using ppa and apt or not.
# Locals:
#  respones_lines
#  found_firefox
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If command was evaluated successfully.
# Outputs:
#  FOUND if firefox is installed using ppa and apt.
#  NOTFOUND if firefox is not installed using ppa and apt.
#######################################
firefox_via_apt(){
    local respons_lines="$(apt list --installed)"
    local found_firefox=$(command_output_contains "firefox" "${respons_lines}")
    echo $found_firefox
}

#######################################
# Checks if firefox is added as ppa or not.
# Locals:
#  respones_lines
#  ppa_indicator
#  found_firefox_ppa
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If command was evaluated successfully.
# Outputs:
#  FOUND if firefox is added as ppa.
#  NOTFOUND if firefox is not added as ppa.
#######################################
firefox_ppa_is_added(){
    # Get list of ppa packages added for apt usage.
    local respons_lines="$(apt policy)"
    # Specify identifier for firefox ppa presence.
    local ppa_indicator="https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu"
    local found_firefox_ppa=$(command_output_contains "$ppa_indicator" "${respons_lines}")
    echo $found_firefox_ppa
}


#######################################
# Remove Firefox if it is installed using snap.
# Locals:
#  respones_lines
#  found_firefox
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If command was evaluated successfully.
# Outputs:
#  FOUND if firefox is installed using snap.
#  NOTFOUND if firefox is not installed using snap.
#######################################
remove_snap_install_firefox_if_existant(){
    if [ "$(firefox_via_snap)" == "FOUND" ]; then
        
        # Prompt user for permission.
        ask_user_swapping_firefox_install_is_ok
        
        # User permission is granted here, remove firefox snap installation.
        yes | sudo snap remove firefox 2>&1
        assert_firefox_is_not_installed_using_snap
        echo "Firefox is removed." > /dev/tty
    fi
    assert_firefox_is_not_installed_using_snap
}

#######################################
# Ask user for permission to swap out Firefox installation.
# Locals:
#  yn
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If command was evaluated successfully.
#  3 If the user terminates the program.
# Outputs:
#  Mesage indicating Firefox will be uninstalled.
#######################################
ask_user_swapping_firefox_install_is_ok(){
    echo "" > /dev/tty
    echo "Hi, firefox is installed using snap. To automatically add your " > /dev/tty
    echo "access tokens to GitHub, we need to control the firefox browser." > /dev/tty
    echo "To control the firefox browser, we need to switch the installation" > /dev/tty
    echo "method from snap to apt." > /dev/tty
    echo "" > /dev/tty
    echo "We will not preserve your bookmarks, history and extensions." > /dev/tty
    echo "" > /dev/tty
    while true; do
        read -p "May we proceed? (y/n)? " yn
        case $yn in
            [Yy]* ) echo "Removing Firefox, please wait 5 minutes, we will tell you when it is done."; break;;
            [Nn]* ) echo "Installation terminated by user."; exit 3;;
            * ) echo "Please answer yes or no." > /dev/tty;;
        esac
    done
}

#######################################
# Asserts Firefox is not installed using snap, throws an error otherwise.
# Locals:
#  None
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If Firefox is not installed using snap.
#  1 If Firefox is still isntalled using snap.
# Outputs:
#  Nothing
#######################################
# Run with:
assert_firefox_is_not_installed_using_snap(){
    if [ "$(firefox_via_snap)" == "FOUND" ]; then
        echo "Error, Firefox installation was still installed using snap." > /dev/tty
        exit 2
    fi
}
assert_firefox_is_installed_using_ppa(){
    if [ "$(firefox_via_apt)" != "FOUND" ]; then
        echo "Error, Firefox installation was not performed using ppa and apt." > /dev/tty
        exit 2
    fi
}

#######################################
# Asserts Firefox ppa is added to apt.
# Locals:
#  None
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If Firefox ppa is added to apt.
#  4 Otherwise.
# Outputs:
#  Error message indicating firefox ppa is not added correctly.
#######################################
# Run with:
assert_firefox_ppa_is_added_to_apt(){
    if [ "$(firefox_ppa_is_added)" == "NOTFOUND" ]; then
        echo "Error, Firefox ppa was not added to apt." > /dev/tty
        exit 4
    fi
}
assert_firefox_ppa_is_removed_from_apt(){
    if [ "$(firefox_ppa_is_added)" == "FOUND" ]; then
        echo "Error, Firefox ppa was not removed from apt." > /dev/tty
        exit 4
    fi
}

#######################################
# Adds firefox ppa to install using apt if it is not added yet.
# Locals:
#  None
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If Firefox is not installed using snap.
#  1 If Firefox is still isntalled using snap.
# Outputs:
#  Nothing
#######################################
add_firefox_ppa_if_not_in_yet(){
    if [ "$(firefox_ppa_is_added)" == "NOTFOUND" ]; then
        echo "Now adding Firefox ppa to apt." > /dev/tty
        echo "" > /dev/tty
        yes | sudo add-apt-repository ppa:mozillateam/ppa
    fi
    assert_firefox_ppa_is_added_to_apt
}
remove_firefox_ppa(){
    if [ "$(firefox_ppa_is_added)" == "FOUND" ]; then
        echo "Now removing Firefox ppa to apt." > /dev/tty
        echo "" > /dev/tty
        yes | sudo add-apt-repository --remove ppa:mozillateam/ppa
    fi
    assert_firefox_ppa_is_removed_from_apt
}


#######################################
# Asserts the Firefox installation package preference is set to ppa/apt. Does
# this by verifying the file content is as expected using hardcoded MD5Sum.
# Locals:
#  None
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If Firefox is not installed using snap.
#  1 If Firefox is still isntalled using snap.
# Outputs:
#  Nothing
#######################################
assert_firefox_installation_package_preference_file_content(){
    local preferences_path="$1"
    local md5_output=$(md5sum $preferences_path)
    local expected_md5_output="961023613b10ce4ae8150f78d698a53e  $preferences_path"
    if [ "$md5_output" != "$expected_md5_output" ]; then
        echo "Error, the md5 output of: $preferences_path is not as expected." > /dev/tty
        echo "md5_output=         $md5_output" > /dev/tty
        echo "expected_md5_output=$expected_md5_output" > /dev/tty
        exit 5
    fi
}

assert_firefox_auto_update_file_content(){
    local preferences_path="$1"
    local md5_output=$(md5sum $preferences_path)
    local expected_md5_output="ffd6e239ef98a236741f4ba5c84ab20e  $preferences_path"
    if [ "$md5_output" != "$expected_md5_output" ]; then
        echo "Error, the md5 output of: $preferences_path is not as expected." > /dev/tty
        echo "md5_output=         $md5_output" > /dev/tty
        echo "expected_md5_output=$expected_md5_output" > /dev/tty
        exit 5
    fi
}


#######################################
# Sets the Firefox installation package preference from snap to ppa/apt.
# Locals:
#  preferences_path
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If Firefox is not installed using snap.
#  1 If Firefox is still isntalled using snap.
# Outputs:
#  Nothing
#######################################
# Run with:
change_firefox_package_priority(){
    local preferences_path="/etc/apt/preferences.d/mozilla-firefox"

    # Set the installation package preference in firefox.
    echo 'Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001' | sudo tee "$preferences_path"

    # Verify the installation package preference is set correctly in firefox.
    assert_firefox_installation_package_preference_file_content "$preferences_path"
}

#######################################
# Ensures the firefox installation is updated automatically.
# Locals:
#  update_filepath
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If Firefox is not installed using snap.
#  1 If Firefox is still isntalled using snap.
# Outputs:
#  Nothing
#######################################
ensure_firefox_is_updated_automatically(){
    local update_filepath="/etc/apt/apt.conf.d/51unattended-upgrades-firefox"
    # Set the installation package preference in firefox.
    echo 'Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";' | sudo tee "$update_filepath"

    # Verify the installation package preference is set correctly in firefox.
    assert_firefox_auto_update_file_content "$update_filepath"
}


#######################################
# Installs firefox using ppa and apt.
# Locals:
#  None
# Globals:
#  None
# Arguments:
#  None
# Returns:
#  0 If Firefox is installed using ppa and apt.
#  1 If Firefox is mpt installed using ppa and apt.
# Outputs:
#  Nothing
#######################################
install_firefox_using_ppa(){
    if [ "$(firefox_via_apt)" == "NOTFOUND" ]; then
        yes | sudo apt install firefox 2>&1
    fi
    assert_firefox_is_installed_using_ppa
    echo "Firefox is installed succesfully using ppa and apt." > /dev/tty
}


# Swap Firefox installation from snap to ppa/apt using functions above.
# 0. Detect how firefox is installed.
# 1. If firefox installed with snap:
# 1.a Ask user for permission to swap out Firefox installation.
# 1.b. Verify and mention the bookmarks, addons and history are not removed.
# 1.c Remove snap firefox if it exists.
# 1.d Verify snap firefox is removed.
remove_snap_install_firefox_if_existant

# 2.a Add firefox ppa to apt if not yet in.
# 2.b Verify firefox ppa is added (successfully).
add_firefox_ppa_if_not_in_yet
#remove_firefox_ppa

# 3.a Change Firefox package priority to ensure it is installed from PPA/deb/apt
# instead of snap.
# 3.b Verify Firefox installation priority was set correctly.
change_firefox_package_priority

# 4.a Ensure the Firefox installation is automatically updated.
# 4.b Verify the auto update command is completed succesfully.
ensure_firefox_is_updated_automatically

# 5.a Install Firefox using apt.
# 5.v Verify firefox is installed succesfully, and only once, using apt/PPA.
install_firefox_using_ppa

0

This was the only thing that worked for me after upgrading to Ubuntu 22.10.

First, remove the Snap version of Firefox:

sudo snap remove firefox

(If you have settings in the Snap version of Firefox under ~/snap/firefox/, you may want to migrate those to ~/.mozilla/firefox/)

Then add the PPA from mozillateam:

sudo add-apt-repository ppa:mozillateam/ppa

Now, the package firefox is provided by both the Ubuntu repos and the Mozilla PPA. The version provided in the Ubuntu repos is a transitional package that actually installs the Snap version of Firefox behind the scenes, which in this case, we don't want. Check that you can see both firefox packages by running:

apt info -a firefox

To prevent the installation of the Snap version of Firefox through the firefox package provided by Ubuntu, we need to modify this file as root, using gnome-text-editor or whichever text editor you prefer:

sudo gnome-text-editor /etc/apt/preferences.d/mozillafirefoxppa

Add these lines:

Package: firefox*
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 501

Package: firefox*
Pin: release o=Ubuntu
Pin-Priority: -1

The first three lines give priority to the firefox packages provided by the Mozilla PPA. And the last three lines disable installing the firefox packages from Ubuntu's repositories.

Run sudo apt update to make sure the changes have been taken into account.

Now, you should be able to install the PPA version of Firefox. You can simulate an installation of Firefox using --dry-run, like this, so as to check which version of Firefox will be installed:

sudo apt install --verbose-versions --dry-run firefox

If you don't see the word snap in the version number of the firefox package (for example: 1:1snap1-0ubuntu2), you are good to go. Run this command to install Firefox (without Snap):

sudo apt install --verbose-versions firefox
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.