...
Install XCode from the Mac App store (the command-line tools are not sufficient) and open it at least once so the developer tools can initialize. This will take a while. After installing, switch to the active developer directory:
Code Block sudo xcode-select -switch /Applications/Xcode.app && sudo xcodebuild -license accept
Install homebrew.
Install the following brew packages:
Code Block brew install autoconf cmake bazelisk make gpatch
Optional:
brew install git
. macOS ships with git, but it's old. This has been a problem in the past, although currently there’s no problem using the version of git that comes with macOS. Once you install git via brew, relaunch your terminal to make sure your git version is up to date. You can confirm this by comparing the output ofCode Block which git
to the output of
Code Block language bash echo $(brew --prefix)/bin/git
If they match, you're using brew's
git
!Install Go. (Note this is not technically a requirement if all you want to do is run builds and tests via Bazel, but generally you will also want to have a toolchain installed for development.)
Code Block brew install go
Other options include:
Official installer via clicking (don't do this)
Official installer via
brew install --cask go
(it's ok) from source (you already know what you're doing, right?)
You should install the same version of Go that the codebase uses. To find what version the codebase uses, check go.mod
. Installing Go with brew install go
may install a more recent version than the codebase is prepared to use.
You can install go with brew install go
. You also have the option of installing by downloading the official tarball. You can also install it from source, although this is not recommended unless you already know what you’re doing.
Install node and javascript tools. As with Go, this is not required to do builds, but if you touch Javascript code at all you’ll want them for development.
Code Block brew install node@16 pnpm yarn
Clone the repo using git and navigate into it
Code Block 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
Add your fork as a remote (assuming you forked cockroach on GitHub)
git remote add yourgithubusername git@github.com:yourgithubusername/cockroach.git
You should be good to start developing. Begin by running
./dev doctor
and following its suggestions to configure your workspace. When the doctor says you’re ready, you can run./dev build
to build the Cockroach binary, or./dev build short
to build the same Cockroach binary without the DB Console, which is faster to compile. See the Developing with Bazel Wiki page for more info.
Cross-compilation
Cross-compilation requires a Docker install on macOS, as you need to be able to run the Linux-host cross toolchains.
...