Build your own trustable Brave Browser

S
SUVANKAR SARKAR
5 min read19 views
Build your own trustable Brave Browser

start building today

requires several dependencies and can take considerable time (1-3 hours depending on your hardware).

Prerequisites

First, ensure you have the necessary system requirements:

At least 8GB RAM (16GB+ recommended)

100GB+ free disk space

64-bit Linux distribution

Python 3.6+

Git

git clone git@github.com:brave/brave-core.git path-to-your-project-folder/src/brave

cd path-to-your-project-folder/src/brave

npm install

# the Chromium source is downloaded, which has a large history (gigabytes of data)

# this might take really long to finish depending on internet speed

npm run init

Step 1: Install Dependencies

For Ubuntu/Debian:

sudo apt update
sudo apt install -y git python3 python3-pip curl build-essential

For Fedora/CentOS/RHEL:

sudo dnf install -y git python3 python3-pip curl gcc-c++ make
# or for older versions: sudo yum install -y git python3 python3-pip curl gcc-c++ make

For Arch Linux:

sudo pacman -S git python python-pip curl base-devel

Step 2: Clone the Repository

git clone https://github.com/brave/brave-browser.git
cd brave-browser

Step 3: Install Node.js and npm

Brave requires a specific Node.js version. Install it using:

# Install Node Version Manager (nvm)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc

Install and use the required Node.js version

nvm install 16
nvm use 16

Step 4: Initialize the Build Environment

# Install Python dependencies
npm install

Initialize and sync the Chromium source

npm run init

This step downloads the Chromium source code and can take 30-60 minutes depending on your internet connection.

Step 5: Build Brave

# Build release version (recommended)
npm run build:Release

Or build debug version (larger, with debugging symbols)

npm run build:Debug

The build process typically takes 1-3 hours depending on your hardware. It will use all available CPU cores.

Step 6: Run the Built Browser

After successful compilation:

# Run the release build
npm start:Release

Or run the debug build

npm start:Debug

Alternative: Using the Build Scripts Directly

You can also use the underlying build scripts:

# After npm run init, you can use:
cd src

Generate build files

gn gen out/Release --args='is_debug=false'

Build with ninja

ninja -C out/Release brave

Troubleshooting Common Issues

Out of memory errors: Ensure you have enough RAM and swap space. Consider adding swap:

   sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Disk space issues: The build requires significant space. Clean up unnecessary files and ensure you have 100GB+ free.

Python version conflicts: Brave's build system is sensitive to Python versions. Ensure you're using Python 3.6+.

Build failures: If the build fails, try:

   npm run clean
npm run init
npm run build:Release

Installing the Built Browser

To install system-wide:

cd src/out/Release
sudo cp brave /usr/local/bin/
sudo cp -r locales /usr/local/share/brave/
sudo cp -r resources /usr/local/share/brave/

Or create a desktop entry:

cat > ~/.local/share/applications/brave-dev.desktop << EOF
[Desktop Entry]
Version=1.0
Name=Brave (Development)
Comment=Browse the web with Brave
Exec=/path/to/brave-browser/src/out/Release/brave
Icon=/path/to/brave-browser/src/out/Release/product_logo_128.png
Terminal=false
Type=Application
Categories=Network;WebBrowser;
EOF

The entire process from start to finish typically takes 2-4 hours for the initial build. Subsequent builds will be faster as they only recompile changed files.

Tags

Share: