Skip to main content
In this section, you’ll explore the structure of a Bazel repository and understand the purpose of each configuration file. By the end, you’ll know where Bazel stores temporary files and how the standard configuration files work together.

What is a Bazel repository?

A Bazel repository is a directory tree containing source files that can be used in a Bazel build. The repository is identified by boundary marker files at its root, such as the REPO.bazel and MODULE.bazel.
In most cases, a Bazel repository corresponds to a Git repository, and this training uses the terms interchangeably. However, Bazel also supports multiple or nested Bazel repositories within a single Git repository.

Starter repository

The codelab repo we cloned from Bazel shell starter contains a pre-configured Bazel repository. Your work repository will have many similar files, but if it uses an older Bazel version, there will be some differences. For example, older Bazel versions relied on a WORKSPACE file to install plugins.

Repository folder structure

Due to historical usage with the Perforce version control system at Google, Bazel always puts the files it creates outside the source tree in temporary folders. Use the bazel info command to see where Bazel stores temporary files:
For convenience, Bazel creates symbolic links from the repository root to certain common temporary folders.
  • bazel-out → $(bazel info execution_root)/bazel-out
  • bazel-bin → bazel-out/[most recent target platform]/bin
  • bazel-testlogs → $(bazel info bazel-testlogs)

Standard Bazel files

  • MODULE.bazel allows this repository to participate in Bazel’s plugin dependency system (called “bzlmod”), either by publishing a module, or declaring dependencies on existing ones. We’ll cover the details in a later section.
  • REPO.bazel is used to specify some common attributes for all build targets inside the repository. This is used with JavaScript to ignore the node_modules folders. See Repo Bazel files.
  • .bazelversion file indicates what version of Bazel should be used. It typically contains the exact version, to ensure identical results between developers and the CI system. However it’s also possible to use “floating” versions like latest. See the bazelisk documentation.
  • .bazelrc stores persistent settings. We’ll cover this in detail in a later section.
  • .bazeliskrc is a less commonly-used configuration for Bazelisk, the version-aware wrapper we installed. This is where the Aspect CLI is selected.
Older Bazel versions required a .bazelignore file instead, but it didn’t support glob patterns making it pretty hard to use. See bazelbuild/bazel#7093.
Now that you understand your repository structure, let’s explore the other files that were created in your starter repository.