.bazelrc configuration files.
Basic flag syntax
Flags are passed to Bazel commands like any command-line program, using double-hyphens such as this:-- marks the boundary where Bazel stops interpreting flags and treats everything that follows as either program arguments or target patterns.
Flag syntax shortcuts
Short form
Some flags have a single-letter short form using a single hyphen:Flag negation
Boolean flags can be negated by addingno as a prefix:
Managing flags with .bazelrc files
Flags are stored in Unix-style RC files so you don’t have to remember and type them repeatedly.
Storing your flag preferences in .bazelrc files allows you to:
- Set system-wide defaults in
/etc/bazel.bazelrc. - Share team configurations in
.bazelrcat the repository root. - Define personal preferences in
$HOME/.bazelrc, these preferences apply to all your Bazel repositories. - Define personal, project-specific preferences in a user.bazelrc file at the repository root, following Bazel’s recommended best practices.
Writing .bazelrc files
In .bazelrc files, each line begins with a command scope, followed by one or more flags.The command scope determines which Bazel commands receive the flag.
common to apply a flag to all commands that support it:
Organizing .bazelrc files as projects grow
In a real project, flags get hard to organize, so we recommend that the .bazelrc file in your project imports from several rc files for convenience. Learn more bazelrc-preset.
A newly created project includes that preset at the start of the file:

