DEV Community

Soumya Lahiri
Soumya Lahiri

Posted on • Edited on

How to Build Firefox on Ubuntu

I'm using Ubuntu 19.10 on my PC. This tutorial focuses on building Firefox for Desktop. Most of the stuff in this post can be found in Mozilla's Developer Guide. I'm creating this post simplifying certain aspects of the process, especially for first-time contributors based on the difficulties I faced when I first contributed to Firefox.

Prerequisites

Python
Ensure you have Python installed on your system. You can check if it is installed by using the following command.

python --version

If you get a message like Python 2.7.17, then you already have Python installed on your system. If you encounter some other error message, you can install Python on your system by the following command.

sudo apt-get install python

You may be prompted for your password.

Mercurial
Mozilla's preferred VCS is Mercurial. While it is possible to use Git for developing Firefox, that procedure is not mentioned in this article. If you aren't aware of what a VCS is, you should probably look that up first. You can check if Mercurial is installed on your system by using the following command.

hg --version

If you get a message showing the version of Mercurial installed alongside other details, then you already have Mercurial installed on your system. If you encounter some other error message, you can install Mercurial on your system by the following command.

sudo apt-get install mercurial

You may be prompted for your password.

Building Firefox

Step 1: Directory Setup
Create a directory where you will clone the source files.

mkdir src && cd src

Step 2: Bootstrapping
Download the bootstrap.py file and place it in the src folder created in the previous step. Now run the following command.

python bootstrap.py

You will be prompted multiple times after this command. Most of the prompts will be asking before downloading certain dependencies for building Firefox. When prompted for choice of VCS, choose Mercurial. When prompted for choice of build, proceed with Firefox for Desktop.

Step 3: Getting the Source Files
Now you need to clone the original source files onto your system. Before executing this step, ensure you have a reliable internet connection and enough storage space on your system. This step can take some time based on your internet speed.

hg clone https://hg.mozilla.org/mozilla-central

Step 4: Build Firefox
After successfully cloning the files, you should find a folder named mozilla-central inside your src folder. Navigate into mozilla-central.

cd mozilla-central

Now comes the final and the most time-consuming step of the whole procedure. This step can take up to 2 hours even on the fastest machines with the latest hardware, or more on older hardware. To build Firefox, run the following command.

./mach build

If the build fails, a good option is to run the following command before trying to build again.

./mach bootstrap

This will check and ensure that the development environment is set up and configured properly. If build failure persists, make sure your source files are up to date by running the following command.

hg pull

You should now be able to build your own copy of Firefox from source. If you have further issues or questions, you can join Mozilla's Developer IRC and ask about your issues there.

Top comments (0)