Open-Source Wikis

/

MongoDB

/

MongoDB

/

Getting started

mongodb/mongo

Getting started

This page summarizes the prerequisites, build commands, and test runner. The canonical reference is docs/building.md; the devcontainer docs describe a reproducible container-based setup.

Prerequisites

A modern C++20 compiler is required. The supported toolchains are:

  • GCC 14.2
  • Clang 19.1
  • Apple Xcode 16.4
  • Visual Studio 2022 17.0+

You also need Python 3.13, libcurl headers, and roughly 13 GB of free disk space for the core binaries.

Install dependencies with your package manager:

OS Command
Fedora / RHEL dnf install libcurl-devel
Ubuntu / Debian apt-get install build-essential libcurl4-openssl-dev liblzma-dev
Amazon Linux yum install xz-devel
macOS brew install llvm@19 lld@19 (Xcode 16.4+ is required for the system toolchain)

Bootstrapping Bazel and Python deps

The repo pins specific versions of Bazel and Python dependencies. The recommended workflow is:

# Install the right bazelisk-managed Bazel version
python buildscripts/install_bazel.py
export PATH=~/.local/bin:$PATH

# Install/refresh Python deps managed by Poetry
buildscripts/poetry_sync.sh

Poetry-managed dependencies are described in pyproject.toml and pinned in poetry.lock. The pre-commit hooks and lint tooling described in Tooling all assume the Poetry virtualenv is active.

Building

The most common build targets:

# Server only
bazel build install-mongod

# Sharding router only
bazel build install-mongos

# mongod + mongos
bazel build install-core

# mongod + mongos + jstestshell (the JS test shell). This is what most contributors build.
bazel build install-devcore

# Full installation tree
bazel build install-dist

If your compiler emits warnings the build doesn't recognize, pass --disable_warnings_as_errors=True.

The output tree is rooted at bazel-bin/install/. For a mongod build it lives at bazel-bin/install/bin/mongod.

The available targets are described in docs/building.md. The build graph itself is defined by per-directory BUILD.bazel files (see e.g. src/mongo/db/BUILD.bazel, the largest at ~120 KB).

Running

A single-node mongod:

sudo mkdir -p /data/db
./bazel-bin/install/bin/mongod

Connect with mongosh (downloaded separately from https://www.mongodb.com/try/download/shell) or, for tests, with the in-tree jstestshell.

Running tests

MongoDB's test runner is resmoke:

# Run a single jstest
buildscripts/resmoke.py run --suites=core jstests/core/find/find1.js

# Run a whole suite
buildscripts/resmoke.py run --suites=replica_sets

# List available suites
buildscripts/resmoke.py list-suites

C++ unit tests are also run via resmoke (suite name unittests). Suite definitions live under buildscripts/resmokeconfig/. See Testing for the full picture.

Where to go next

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Getting started – MongoDB wiki | Factory