Bug 1731282 [wpt PR 30785] - Fix endpoint URL for a COEP navigation reporting test...
[gecko.git] / docs / setup / linux_build.rst
blobab3f1063c096928d46059459bc9d949bb512f312
1 Building Firefox On Linux
2 =========================
4 This document will help you get set up to build Firefox on your own
5 computer. Getting set up can take a while - we need to download a
6 lot of bytes! Even on a fast connection, this can take ten to fifteen
7 minutes of work, spread out over an hour or two.
9 Requirements
10 ------------
12 -  **Memory:** 4GB RAM minimum, 8GB+ recommended.
13 -  **Disk Space:** At least 30GB of free disk space.
14 -  **Operating System:** A 64-bit installation of Linux. It is strongly advised
15    that you use a supported distribution; see :ref:`build_hosts`.  We also
16    recommend that your system is fully up-to-date.
18 .. note::
20     Some Linux distros are better-supported than others. Mozilla maintains
21     bootstrapping code for Ubuntu, but others are managed by the
22     community (thanks!). The more esoteric the distro you're using,
23     the more likely that you'll need to solve unexpected problems.
26 1. System preparation
27 ---------------------
29 1.1 Install Python
30 ~~~~~~~~~~~~~~~~~~
32 To build Firefox, it's necessary to have a Python of version 3.6 or later
33 installed. Python 2 is no longer required to build Firefox, although it is still
34 required for running some kinds of tests. Additionally, you will probably need
35 Python development files as well to install some pip packages.
37 You should be able to install Python using your system package manager:
39 -  For Debian-based Linux (such as Ubuntu): ``sudo apt-get install python3 python3-dev``
40 -  For Fedora Linux: ``sudo dnf install python3 python3-devel``
42 If you need a version of Python that your package manager doesn't have (e.g.:
43 the provided Python 3 is too old, or you want Python 2 but it's not available),
44 then you can use `pyenv <https://github.com/pyenv/pyenv>`_, assuming that your
45 system is supported.
47 1.2 Install Mercurial
48 ~~~~~~~~~~~~~~~~~~~~~
50 Mozilla's source code is hosted in Mercurial repositories. You will
51 need Mercurial to download and update the code.
53 Note that if you'd prefer to use the version of Mercurial that is
54 packaged by your distro, you can skip this section. However, keep in
55 mind that distro-packaged Mercurial may be outdated, and therefore
56 slower and less supported.
58 .. code-block:: shell
60     python3 -m pip install --user mercurial
62 You can test that Mercurial is installed by running:
64 .. code-block:: shell
66     hg version
68 .. note::
70     If your shell is showing ``command not found: hg``, then Python's packages aren't
71     being found in the ``$PATH``. You can resolve this by doing the following and
72     restarting your shell:
74     .. code-block:: shell
76         # If you're using zsh
77         echo "export PATH=\"$(python3 -m site --user-base)/bin:$PATH\"" >> ~/.zshenv
79         # If you're using bash
80         echo "export PATH=\"$(python3 -m site --user-base)/bin:$PATH\"" >> ~/.bashrc
82         # If you're using a different shell, follow its documentation to see
83         # how to configure your PATH. Ensure that `$(python3 -m site --user-base)/bin`
84         # is prepended.
86 2. Bootstrap a copy of the Firefox source code
87 ----------------------------------------------
89 Now that your system is ready, we can download the source code and have Firefox
90 automatically download the other dependencies it needs. The below command
91 will download a lot of data (years of Firefox history!) then guide you through
92 the interactive setup process.
94 .. code-block:: shell
96     curl https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py -O
97     python3 bootstrap.py
99 .. note::
101     In general, the Firefox workflow works best with Mercurial. However,
102     if you'd prefer to use ``git``, you can grab the source code in
103     "git" form by running the bootstrap script with the ``vcs`` parameter:
105     .. code-block:: shell
107         python3 bootstrap.py --vcs=git
109     This uses `Git Cinnabar <https://github.com/glandium/git-cinnabar/>`_ under the hood.
111 Choosing a build type
112 ~~~~~~~~~~~~~~~~~~~~~
114 If you aren't modifying the Firefox backend, then then select one of the
115 :ref:`Artifact Mode <Understanding Artifact Builds>` options. If you are
116 building Firefox for Android, you should also see the :ref:`GeckoView Contributor Guide`.
118 3. Build
119 --------
121 Now that your system is bootstrapped, you should be able to build!
123 .. code-block:: shell
125     rm bootstrap.py
126     cd mozilla-unified
127     ./mach build
128     ./mach run
130 🎉 Congratulations! You've built your own home-grown Firefox!
132 Now the fun starts
133 ------------------
135 Time to start hacking! You should join us on `Matrix <https://chat.mozilla.org/>`_,
136 say hello in the `Introduction channel
137 <https://chat.mozilla.org/#/room/#introduction:mozilla.org>`_, and `find a bug to
138 start working on <https://codetribute.mozilla.org/>`_.
139 See the :ref:`Firefox Contributors' Quick Reference` to learn how to test your changes,
140 send patches to Mozilla, update your source code locally, and more.
142 Troubleshooting
143 ---------------
145 Using a non-native file system (NTFS, network drive, etc)
146 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148 In our experience building Firefox in these hybrid or otherwise complex environments
149 always ends in unexpected, often silent and always hard-to-diagnose failure.
150 Building Firefox in that environment is far more likely to reveal the flaws and
151 shortcomings of those systems than it is to produce a running web browser.