Useful general options
The following flags are meant to be set explicitly on the command line.—config
You can organize flags in a.bazelrc file into configurations, like ones for debugging or release builds. Additional configuration groups can be selected with --config=<group>.
See command line reference
—keep_going
Bazel should try as much as possible to continue with build and test execution. By default, Bazel fails eagerly. See command line reference—remote_download_outputs
When using remote execution or caching (both disk and remote), you can signal to Bazel that you want to download all (intermediate) build artifacts as follows:—stamp
Adds build info (user, timestamp) to binaries.Because this increases build time, it’s only intended for release builds.
Uncover Build & Test Issues
The following flags can help you better understand Bazel build or test errors.—announce_rc
Shows which flags are implicitly set through user-defined, machine-defined, or project-defined.bazelrc files.
See command line reference
—auto_output_filter
By default, Bazel tries to prevent log spam and does only print compiler warnings and Starlark debug output for packages and subpackages requested on the command line. To disable all filtering, set--auto_output_filter=none.
See command line reference
—sandbox_debug
Lets you drill into sandboxing errors. For details on why Bazel sandboxes builds by default and what gets sandboxed, see our sandboxing documentation. See command line reference—subcommands (-s)
Displays a comprehensive list of every command that Bazel runs during a build, regardless of whether it succeeds or fails. See command line referenceStartup
—bazelrc
You can specify default Bazel options in.bazelrc files. If multiple .bazelrc files exist, you can select which one to use with --bazelrc=/path/to/.bazelrc.
To ignore all .bazelrc files, use --bazelrc=/dev/null.
See command line reference
—output_base
Bazel stores all data at~/.cache/bazel/_bazel_$USER by default. If this directory is on a network drive, you may want to relocate it to local storage using --output_base=/path/to/base.
See command line reference
Set Bazelrc files
You can control which.bazelrc files Bazel reads and in what order.
—bazelrc
Specifies the path to a.bazelrc file to use. Can be passed multiple times.
See command line reference
—nosystem_rc
Prevents reading system-wide.bazelrc files.
See command line reference
—noworkspace_rc
Prevents reading workspace.bazelrc files.
See command line reference
—nohome_rc
Prevents reading home directory.bazelrc files.
See command line reference
Building and Testing
Flags for optimizing your build and test workflows.—jobs (-j)
Controls how many parallel jobs Bazel runs. The default is based on your host’s capacity. Setting it too high may cause thrashing, while setting it too low underutilizes resources.—local_resources
Explicitly sets the amount of local resources (RAM, CPU) that Bazel can use. Useful when running builds on machines with limited resources.—test_output
Controls how test output is displayed:summary- shows only final summary (default)errors- shows output from failed testsall- shows all test outputstreamed- streams test output in real-time
—test_filter
Runs only tests whose names match the specified pattern. Useful for running a subset of tests.—cache_test_results
Controls whether test results are cached. Set tono or false to force tests to re-run even if nothing has changed.
Remote Execution and Caching
Flags for configuring remote build execution and caching.—remote_executor
Specifies the remote execution endpoint.—remote_cache
Specifies the remote cache endpoint.—remote_timeout
Sets the timeout for remote execution and cache operations.Debugging
Flags to help debug build issues.—explain
Generates a detailed explanation of why each action was executed, writing it to the specified file.—verbose_explanations
Provides more detailed explanations when used with--explain.
See command line reference
—profile
Generates a JSON profile of the build, useful for performance analysis.bazel analyze-profile profile.json.
See command line reference
Output Control
—output_filter
Filters build output to show only messages from targets matching the specified pattern.—show_progress
Controls whether to show progress messages during build. See command line reference—show_progress_rate_limit
Sets the minimum time between progress updates (in seconds).Sandboxing
—spawn_strategy
Controls the execution strategy for actions. Common values:sandboxed- run in sandbox (default on Linux/macOS)local- run without sandboxingworker- use persistent worker processesremote- execute remotely
—sandbox_tmpfs_path
Mounts a temporary filesystem at the specified path within the sandbox. Can improve performance for heavy I/O operations.Configuration
—compilation_mode (-c)
Sets the compilation mode:fastbuild- fast compilation with minimal optimizations (default)opt- optimized build for releasedbg- debug build with symbols
—platforms
Specifies the target platform for the build.—cpu
Specifies the target CPU architecture. Being replaced by--platforms.