bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.77k stars 3.99k forks source link

support disabling --remote_* flags on the command line. #4595

Open sgreenstein opened 6 years ago

sgreenstein commented 6 years ago

Description of the problem / feature request:

If a flag that defaults to null is passed in .bazelrc or bazel.rc, it is impossible to set it to null on the command line.

Feature requests: what underlying problem are you trying to solve with this feature?

Enable remote caching by default, but be able to disable it on the command line. To do this I specify the remote caching flags in bazel.rc, but wish to override them on the command line, which isn't possible.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

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

It is now impossible to set --google_credentials to null so that it doesn't look for a key:

sgreens@sgreens0$ bazel build ... --google_credentials=
ERROR: Could not open auth credentials file '':  (No such file or directory)
INFO: Streaming Build Event Protocol to buildeventservice.googleapis.com build_request_id: xxx invocation_id: xxx
ERROR: Build Event Protocol upload failed: Could not open auth credentials file '':  (No such file or directory)
java.lang.NullPointerException
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:871)
    at com.google.devtools.build.lib.events.Event.<init>(Event.java:52)
    at com.google.devtools.build.lib.events.Event.error(Event.java:165)
    at com.google.devtools.build.lib.events.Event.error(Event.java:200)
    at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:474)
    at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:218)
    at com.google.devtools.build.lib.runtime.CommandExecutor.exec(CommandExecutor.java:58)
    at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:851)
    at com.google.devtools.build.lib.server.GrpcServerImpl.access$2100(GrpcServerImpl.java:109)
    at com.google.devtools.build.lib.server.GrpcServerImpl$2.lambda$run$0(GrpcServerImpl.java:916)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
java.lang.NullPointerException
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:871)
    at com.google.devtools.build.lib.events.Event.<init>(Event.java:52)
    at com.google.devtools.build.lib.events.Event.error(Event.java:165)
    at com.google.devtools.build.lib.events.Event.error(Event.java:200)
    at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:474)
    at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:218)
    at com.google.devtools.build.lib.runtime.CommandExecutor.exec(CommandExecutor.java:58)
    at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:851)
    at com.google.devtools.build.lib.server.GrpcServerImpl.access$2100(GrpcServerImpl.java:109)
    at com.google.devtools.build.lib.server.GrpcServerImpl$2.lambda$run$0(GrpcServerImpl.java:916)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

What operating system are you running Bazel on?

Rodete

What's the output of bazel info release?

0.10.0

Have you found anything relevant by searching the web?

https://stackoverflow.com/questions/48652798/how-do-i-unset-flags-set-in-bazelrc/

philwo commented 6 years ago

Thanks for the report @sgreenstein! This looks like a pretty straightforward fix. I'll change our options for remote execution / caching to not use null to indicate the default, but instead an empty string.

philwo commented 6 years ago

FYI @buchgr

buchgr commented 6 years ago

will fix.

jparismorgan commented 2 years ago

Hi there, I am also impacted by the same issue. @philwo / @buchgr, do you know if this is still planned to be fixed? @sgreenstein, did you find a workaround to this? Thanks!