---
title: "Build the source code"
url: "https://docs.yugabyte.com/stable/contribute/core-database/build-from-src-macos/"
---

# Build the source code

Build YugabyteDB from source code on macOS.

Build the source code.

- [AlmaLinux](/stable/contribute/core-database/build-from-src-almalinux/)
- [macOS](/stable/contribute/core-database/build-from-src-macos/)
- [Ubuntu](/stable/contribute/core-database/build-from-src-ubuntu/)

Note

AlmaLinux 8 is the recommended Linux development platform for YugabyteDB.

## Install necessary packages

First, install [Homebrew](https://brew.sh/ "Homebrew"), if you do not already have it. Homebrew is used to install the other required packages.

```sh
/usr/bin/ruby -e "$(
  curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```

Install the following packages using Homebrew:

```sh
brew install autoconf automake bash ccache cmake coreutils gnu-tar libtool \
             ninja pkg-config pstree wget python
```

Note

YugabyteDB build scripts require at least Bash version 4. Make sure that `bash --version` outputs a version of 4 or higher before proceeding. You may need to put `/usr/local/bin` (Intel) or `/opt/homebrew/bin` (Apple Silicon) as the first directory on `PATH` in your `~/.bashrc` to achieve that.

### /opt/yb-build

By default, when running build, third-party libraries are not built, and pre-built libraries are downloaded. The build scripts automatically install these in directories under `/opt/yb-build`. In order for the build script to write under those directories, it needs proper permissions. One way to do that is as follows:

```sh
sudo mkdir /opt/yb-build
sudo chown "$USER" /opt/yb-build
```

Alternatively, specify the build options `--no-download-thirdparty`. Note that those options may require additional, undocumented steps.

### Java

YugabyteDB core is written in C and C++, but the repository contains Java code needed to run some tests and sample applications. To build the Java part, you need:

- Java Development Kit (JDK) 8 or 11.
- [Apache Maven](https://maven.apache.org/ "Apache Maven") 3.3 or later.

Install the following packages to satisfy those requirements:

```sh
brew install openjdk@11 maven
```

Don't forget to add JDK binaries to `PATH`, ensuring this version takes precedence. For example,

```sh
# On apple silicon mac.
echo 'export PATH="/opt/local/homebrew/opt/openjdk@11/bin:$PATH"' >>~/.bashrc
# On intel mac.
echo 'export PATH="/usr/local/opt/openjdk@11/bin:$PATH"' >>~/.bashrc
```

### yugabyted-ui

yugabyted-ui is a UI for [yugabyted](/stable/reference/configuration/yugabyted "yugabyted"). By default, it is not built unless the corresponding build option is specified or a release package is being built. To build it, [npm](https://www.npmjs.com "npm") and [Go](https://go.dev "Go") 1.20 or higher are required.

## Build the code

Assuming [this repository](https://github.com/yugabyte/yugabyte-db "this repository") is checked out in `~/code/yugabyte-db`, do the following:

```sh
cd ~/code/yugabyte-db
./yb_build.sh release
```

The command above will build the release configuration, add the binaries into the `build/release-<compiler>-dynamic-ninja` directory, and create a `build/latest` symlink to that directory.

Note

If you see errors, such as `internal compiler error: Killed`, the system has probably run out of memory. Try again by running the build script with less concurrency, for example, `-j1`.

Note

If you get an error message such as

> ValueError: Found no third-party release archives to download for OS type ubuntu20.04, compiler type matching gcc11, architecture x86\_64, is\_linuxbrew=False. See more details above.

it means that there is no [third-party download](#opt-yb-build "third-party download") available for that build configuration. Check the output that precedes the message for supported configurations.

For more details about building and testing, refer to [Build and test](/stable/contribute/core-database/build-and-test "Build and test").

### Build release package (optional)

Perform the following steps to build a release package:

1. [Satisfy requirements for building yugabyted-ui](#yugabyted-ui "Satisfy requirements for building yugabyted-ui").
2. Run the `yb_release` script using the following command:
   
   ```sh
   ./yb_release
   ```
   
   ```output.sh
   ......
   2020-10-27 13:55:40,856 [yb_release.py:283 INFO] Generated a package at '/Users/me/code/yugabyte-db/build/yugabyte-2.5.1.0-6ab8013159fdca00ced7e6f5d2f98cacac6a536a-release-darwin-x86_64.tar.gz'
   ```
