bazel
bazel copied to clipboard
Explicitly requesting an incompatible target prints errors twice
Description of the bug:
Explicitly requesting an incompatible target on the command line currently results in duplicated error messages.
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Empty WORKSPACE
file
BUILD
file:
load(":example.bzl", "custom_rule")
custom_rule(
name = "target1",
target_compatible_with = ["@platforms//:incompatible"],
)
example.bzl
file:
def _custom_rule_impl(ctx):
pass
custom_rule = rule(
implementation = _custom_rule_impl,
)
.bazelversion
file (with bazelisk):
4ff441b13db6b6f5d5d317881c6383f510709b19
Results in this:
$ bazel --nohome_rc build //:target1
2022/05/08 21:51:46 Using unreleased version at commit 4ff441b13db6b6f5d5d317881c6383f510709b19
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/home/phil/.bazelrc
ERROR: Target //:target1 is incompatible and cannot be built, but was explicitly requested.
Dependency chain:
//:target1 <-- target platform (@local_config_platform//:host) didn't satisfy constraint @platforms//:incompatible: Target //:target1 is incompatible and cannot be built, but was explicitly requested.
Dependency chain:
//:target1 <-- target platform (@local_config_platform//:host) didn't satisfy constraint @platforms//:incompatible
INFO: Elapsed time: 0.061s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
Notice the duplicated error.
Which operating system are you running Bazel on?
x86_64 Debian 11
What is the output of bazel info release
?
$ bazel info release
2022/05/08 21:58:07 Using unreleased version at commit 4ff441b13db6b6f5d5d317881c6383f510709b19
INFO: Invocation ID: 5166a50f-6e61-491f-b637-154e577ebd76
development version
If bazel info release
returns development version
or (@non-git)
, tell us how you built Bazel.
I didn't build it. I used bazelisk to download a development version.
What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD
?
N/A
Have you found anything relevant by searching the web?
This appears similar to #12146 and #11960, but seem different enough that I thought it warranted a separate issue. This issue here is not triggered by --verbose_failures
.
Any other information, logs, or outputs that you want to share?
This does not happen with bazel 5.1.1.
@gregestren , FYI in case it's interesting.
I suspect it's got nothing to do with incompatible target skipping. I'm not sure what the cause might be.
I've run into this theme before. I think it can happen for different reasons.
Do you know if --keep_going
affects this?
I committed https://github.com/bazelbuild/bazel/commit/c56497707f283f3aa1ab34abbcb88470fb5f3207 a while ago to handle another case.
Interesting! With --keep_going
the dependency chain explanation disappears completely:
$ bazel --nohome_rc build //:target1 --keep_going
2022/05/09 21:42:29 Using unreleased version at commit 4ff441b13db6b6f5d5d317881c6383f510709b19
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/home/phil/.bazelrc
WARNING: Target //:target1 is incompatible and cannot be built, but was explicitly requested.
INFO: Analyzed target //:target1 (0 packages loaded, 0 targets configured).
INFO: Found 0 targets...
ERROR: command succeeded, but not all targets were analyzed
INFO: Elapsed time: 0.149s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
FAILED: Build did NOT complete successfully
I'm guessing that makes sense though since with --keep_going
you're essentially telling bazel not to worry about individual errors.
After bisecting, it looks like this issue was introduced in e8a99923af0a017e68afa3007eff01229df54f81 (https://bazel-review.googlesource.com/c/bazel/+/196876). @joeleba , would you happen to know what might be causing this? I haven't looked into it yet, but hope to do so in the next few weeks.
I haven't looked super closely yet, but it's most likely the wrapping of exceptions (e.g. TargetCompatibilityCheckException
by ViewCreationFailedException
) that's causing this.
I hope this is just a visual thing and it's not impacting your productivity, as I unfortunately don't have the bandwidth now to treat this with urgency :(
Definitely not blocking anything. Just something I am hoping to resolve before bazel 6. I am hoping to investigate a potential solution in the next few weeks.
@joeleba , I pushed #16178 for your consideration.