Note that at least 4GB of RAM is required to build from source and run tests.
If you are on macOS, you may find the Building from source on macOS documentation useful.
Either a working Docker install able to run GNU/Linux binaries (e.g. Docker on Linux, macOS, Windows), so you can reuse our pre-populated Docker image with all necessary development dependencies; or
If using Bazel to build Cockroach (preferred for
master and v22.1 onward), the following dependencies are required:
A C++ compiler that supports C++11. Note that GCC prior to 6.0 doesn't work due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48891
The standard C/C++ development headers on your system.
On GNU/Linux, the terminfo development libraries, which may beÂ part of a ncurses development package (e.g. `libncurses-dev` on Debian/Ubuntu, but `ncurses-devel` on CentOS). You also need the
libresolv-wrapper package on Ubuntu < 22.04.
Git 1.9+, we recommend v2.20+
Bash (4+ is preferred)
GNU Make (4.2+ is known to work)
CMake 3.20.* (on Macs 3.21+ are also known to work)
Yacc or Bison
GNU Patch 2.7+
Bazelisk (you can use Bazel directly instead of Bazelisk, although Bazelisk makes sure youâre using the same version that we use in CI)
If you're running macOS, a full installation of XCode is necessary.
make to build Cockroach (preferred for v21.2 and prior, deprecated from 22.1 onward), all the dependencies above are required plus:
A Go environment with a recent 64-bit version of the toolchain. Note that the Makefile enforces the specific version required, as it is updated frequently.
NodeJS 12.x and Yarn 1.7+
git to fetch the source code to an appropriate location:
git clone https://github.com/cockroachdb/cockroach
If you are using
make to build Cockroach, you must root your
cockroach repo correctly relative to
$GOPATH. Otherwise, builds will fail.
mkdir -p $(go env GOPATH)/src/github.com/cockroachdb cd $(go env GOPATH)/src/github.com/cockroachdb git clone https://github.com/cockroachdb/cockroach cd cockroach
If building with Bazel, see the Developing with Bazel documentation. Otherwise, continue reading.
make is deprecated for building v22.1+ of
cockroach, but still the preferred build system for v21.2 or prior.
make test, or anything else our Makefile offers.
Note:Â you might need to runÂ
make clean first if you're seeing an error likeÂ
make: /usr/local/Cellar/cmake/3.13.4/bin/cmake: No such file or directory.
If you wish to reuse our builder image instead of installing all the dependencies manually, prefix the
make command with
build/builder.sh; for example
build/builder.sh make build.
Note that the first time you run
make, it can take some time to download and install various dependencies. After running
make build, the
cockroach executable will be in your current directory and can be run as shown in Starting with CockroachDB.
Note that if you use the builder image, you should ensure that your Docker installation grants 4GB or more of RAM to containers. On some systems, the default configuration limits containers to 2GB memory usage and this can be insufficient to build/link a CockroachDB executable.
See alsoÂ Building from source on macOS