How to Build Firefox

By  on  

Firefox Nightly Open source is a dream and a gateway to an amazing career -- I'm a testament to that. One of the most amazing open source projects to ever exist, Mozilla Firefox, is a project I'm proud to work on as an employee of Mozilla. It's rewarding, challenging, and a unique experience...and I want you to join me!

Take a few moments with me to learn how to build the amazing Firefox!

Step 1: Clone Mozilla Central

Mozilla Central is the name of the mercurial repository that contains the source code of Firefox. Start by installing mercurial and cloning "MC":

hg clone

hg clone {repo_url} is the first and most basic mercurial command, but check out my Mercurial Productivity Tips post to learn more hg commands! "MC" will be installed in a mozilla-central directory.

Step 2: Install Dependencies

From C++ to Rust, Firefox has a fair bit of requirements you'll need to install. From within the mozilla-central directory, run the following:

./mach bootstrap

The bootstrap command will install dependencies as well as configure mercurial extensions as required. Congratulations -- you're now ready to build!

Step 3: Create a mozconfig

You'll thank me for this one! Create a mozconfig file to use artifact builds, which will save loads of time during the build process by downloading pre-built binaries for Firefox's internals.

# Automatically download and use compiled C++ components:
ac_add_options --enable-artifact-builds

# Write build artifacts to:
mk_add_options MOZ_OBJDIR=./objdir-frontend

Place the code above in your mozconfig file and you're builds will be super fast!

Step 4: Build!

Once you have the code and the dependencies, it's time to build the amazing Firefox! You can build Firefox with the following command:

./mach build

Hello Firefox!

Step 5: Run Firefox

Once you've built the amazing Firefox, you can run Firefox with the following mach command:

./mach run --jsdebugger

Congratulations! You've taken the Firefox source code and turned it into an application that you can run! The --jsdebugger option opens the "browser toolbox" which allows you to debug the Firefox you've just built.

Updating Mozilla Central Code

The Mozilla Central repository is updated several times a day as Mozilla employees and contributors like you submit patches. You can update your local checkout with the following:

hg pull && hg update --clean

You local commits will always be draft status while patches which have been merged into MC will be public status.

Configuring Options

Whenever Firefox developer and the community develop new features, they're hidden behind a preference until the feature reaches maturity. To toggle feature flags, you can visit about:config in your local Firefox or any Firefox release.


The config page allows you to toggle and set a number of options. Many "edge" features debut behind feature flags in Firefox Nightly.

Congratulations! You've turned a massive repository of code into a living, breathing Firefox web browser! In the next post in the Firefox series, we'll explore contribution and testing!

Recent Features

  • By
    I’m an Impostor

    This is the hardest thing I've ever had to write, much less admit to myself.  I've written resignation letters from jobs I've loved, I've ended relationships, I've failed at a host of tasks, and let myself down in my life.  All of those feelings were very...

  • By
    Creating Scrolling Parallax Effects with CSS

    Introduction For quite a long time now websites with the so called "parallax" effect have been really popular. In case you have not heard of this effect, it basically includes different layers of images that are moving in different directions or with different speed. This leads to a...

Incredible Demos


  1. Jørgen Østensen

    Could you say something how to build support for gpsd? I have application that are made with javascript dependent on GPS for use in a sail boat. I need to compile Firefox with support for gpsd. I plan to use the browser with raspberry pi and Linux.

  2. Sandeep

    Hi, While trying to build. I am getting this error. I am new to building from source code.

    I have following error:

     0:04.72 checking whether the C compiler supports -Wformat-overflow=2... yes
     0:04.76 checking whether the C++ compiler supports -Wformat-overflow=2... yes
     0:04.80 checking whether the C compiler supports -Wno-gnu-zero-variadic-macro-arguments... no
     0:04.82 checking whether the C++ compiler supports -Wno-gnu-zero-variadic-macro-arguments... no
     0:04.87 checking whether the C++ compiler supports -fno-sized-deallocation... yes
     0:04.91 checking whether the C++ compiler supports -fno-aligned-new... yes
     0:04.93 checking for libpulse... yes
     0:04.94 checking MOZ_PULSEAUDIO_CFLAGS... -D_REENTRANT
     0:04.95 checking MOZ_PULSEAUDIO_LIBS... -lpulse
     0:04.95 checking for rustc... not found
     0:04.95 checking for cargo... not found
     0:04.95 Traceback (most recent call last):
     0:04.95   File "/home/panda/mozilla-central/", line 164, in <module>
     0:04.95     sys.exit(main(sys.argv))
     0:04.95   File "/home/panda/mozilla-central/", line 40, in main
     0:04.95, 'moz.configure'))
     0:04.95   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/configure/", line 499, in run
     0:04.96     func(*args)
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/configure/", line 543, in _value_for
     0:04.96     return self._value_for_depends(obj)
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/", line 963, in method_call
     0:04.96     cache[args] = self.func(instance, *args)
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/configure/", line 552, in _value_for_depends
     0:04.96     value = obj.result()
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/", line 963, in method_call
     0:04.96     cache[args] = self.func(instance, *args)
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/configure/", line 155, in result
     0:04.96     return self._func(*resolved_args)
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/configure/", line 1152, in wrapped
     0:04.96     return new_func(*args, **kwargs)
     0:04.96   File "/home/panda/mozilla-central/build/moz.configure/rust.configure", line 59, in unwrap
     0:04.96     (retcode, stdout, stderr) = get_cmd_output(prog, '+stable')
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/configure/", line 1152, in wrapped
     0:04.96     return new_func(*args, **kwargs)
     0:04.96   File "/home/panda/mozilla-central/build/moz.configure/util.configure", line 30, in get_cmd_output
     0:04.96     log.debug('Executing: %s', quote(*args))
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/", line 210, in quote
     0:04.96     return ' '.join(_quote(s) for s in strings)
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/", line 210, in <genexpr>
     0:04.96     return ' '.join(_quote(s) for s in strings)
     0:04.96   File "/home/panda/mozilla-central/python/mozbuild/mozbuild/", line 198, in _quote
     0:04.96     return t("'%s'") % s.replace(t("'"), t("'\\''"))
     0:04.96 TypeError: cannot create 'NoneType' instances
     0:05.02 *** Fix above errors and then restart with\
     0:05.02                "./mach build"
     0:05.02 recipe for target 'configure' failed
     0:05.02 make: *** [configure] Error 1
  3. To save the next person downloading 7+GB and more than 800k files: the build does not work on Raspbian/Raspberry Pi OS. It fails at the OS check, and if you bypass that by editing the bootstrap script to make it see the system as Debian (which it is) then it later fails in the Rust initialization, where it seems to think the system is an x86/64 (it’s an ARM).

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!