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

Install prerequisites

If you are on macOS, you may find the Building from source on macOS documentation useful.

Get the CockroachDB code

Use git to fetch the source code to an appropriate location:

git clone

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/
cd $(go env GOPATH)/src/
git clone
cd cockroach

Next steps

If building with Bazel, see the Developing with Bazel documentation. Otherwise, continue reading.

(deprecated) Building with make

make is deprecated for building v22.1+ of cockroach, but still the preferred build system for v21.2 or prior.

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 

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