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
    How I Stopped WordPress Comment Spam

    I love almost every part of being a tech blogger:  learning, preaching, bantering, researching.  The one part about blogging that I absolutely loathe:  dealing with SPAM comments.  For the past two years, my blog has registered 8,000+ SPAM comments per day.  PER DAY.  Bloating my database...

  • By
    Tips for Starting with Bitcoin and Cryptocurrencies

    One of the most rewarding experiences of my life, both financially and logically, has been buying and managing cryptocurrencies like Bitcoin, Litecoin, Ethereum. Like learning any other new tech, I made rookie mistakes along the way, but learned some best practices along the way. Check out...

Incredible Demos

  • By
    Using Opacity to Show Focus with MooTools

    I'm a huge fan of using subtle effects like link nudging (jQuery, MooTools) to enhance the user experience and increase the perceived dynamism of my websites. Trust me -- a lot of little things are what take websites to the next level.

  • By
    MooTools Fun with Fx.Shake

    Adding movement to your website is a great way to attract attention to specific elements that you want users to notice. Of course you could use Flash or an animated GIF to achieve the movement effect but graphics can be difficult to maintain. Enter...


  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!