Getting and building CockroachDB from source

Note that at least 4GB of RAM is required to build from source and run tests.

Install prerequisites

  • 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

  • The tools needed to build CockroachDB from scratch:

    • A C++ compiler that supports C++11. Note that GCC prior to 6.0 doesn't work due to

    • 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).

    • 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.

    • Git 1.9+, we recommend v2.20+

    • Bash (4+ is preferred)

    • GNU Make (4.2+ is known to work)

    • CMake 3.8+

    • Autoconf 2.68+

    • NodeJS 12.x and Yarn 1.7+

    • Yacc or Bison

    • 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.

Get the CockroachDB code

1 2 3 4 mkdir -p $(go env GOPATH)/src/ cd $(go env GOPATH)/src/ git clone cd cockroach

Note: it is important to ensure the CockroachDB sources are positioned correctly relative to `$GOPATH`. Otherwise, the builds will fail.

Run make

Run `make build`, `make test`, or anything else our Makefile offers.
Note: you might need to run make clean first if you're seeing an error like 

1 make[1]: /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/; for example build/ 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