My bazel.rc has flags that set up remote caching, but in certain situations I want to disable it, e.g. when running in an environment with network restrictions.
How do I "unset" the flags set in bazel.rc? For instance, bazel.rc sets --google_credentials=/path/to/key
, so how do I override that and pass in null so it doesn't look for credentials?
I would like to retain the rest of my bazel.rc, so I don't want to simply ignore it.
Partial bazel.rc:
build --google_credentials=/path/to/key
build --google_default_credentials
build --google_auth_scopes=https://www.googleapis.com/auth/cloud-source-tools
build --bes_backend=buildeventservice.googleapis.com
build --bes_best_effort=false
build --bes_timeout=10s
build --project_id=123456
build --remote_cache=remotebuildexecution.googleapis.com
build --remote_instance_name=projects/myproject
build --spawn_strategy=remote
build --genrule_strategy=remote
build --tls_enabled=1
build --remote_accept_cached=true
Flags specified on the command line will override anything in the bazelrc file. So you can specify --google_credentials=
to clear the value.
There are also other ways to set this up. In your case say you want --foo=1 --bar=2
by default, but sometimes you want to turn those off. It would be annoying to have to remember all the flags to turn things off, so you can create configs. Your bazelrc
file would look like this:
build --foo=1 --bar=2
build:nofoo --foo= --bar=
When do bazel build
normally, you get --foo=1
and --bar=2
. When you don't want foo
and bar
you do bazel build --config=nofoo
, which expands to bazel build --foo=1 --bar=2 --foo= --bar=
, where the later flags will override the previous flags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With