`target_compatible_with` with `genquery` fails in cases where `query` would succeed
See original GitHub issueWith this root BUILD file:
constraint_setting(name = "incompatible_setting")
constraint_value(
name = "incompatible",
constraint_setting = ":incompatible_setting",
)
sh_test(
name = "bar",
srcs = ["BUILD"],
target_compatible_with = ["//:incompatible"],
)
genquery(
name = "query",
testonly = True,
expression = "//:bar",
scope = ["//:bar"],
)
If you run bazel build //:query
you get this failure:
% bazel build //:query
ERROR: Target //:query is incompatible and cannot be built, but was explicitly requested.
Dependency chain:
//:query
//:bar <-- target platform didn't satisfy constraint //:incompatible
INFO: Elapsed time: 0.075s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 5 targets configured)
Interestingly if you omit the //:
from the target, it skips the genquery
all together:
% bazel build query
INFO: Analyzed target //:query (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:query was skipped
INFO: Elapsed time: 0.100s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
If you just query this target, it works:
% bazel query //:bar
//:bar
I’m not sure what the expectations are around genquery and it’s similarity to query, but it would be ideal in this case if genquery would also succeed. Also I think the difference in behavior when you have //:
or not is unexpected.
What operating system are you running Bazel on?
macOS
What’s the output of bazel info release
?
release 4.0.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
General Rules | Bazel
Queries violating this rule will fail during execution if strict is unspecified or true (if strict is false, the out of scope targets...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
At the very least I should fix the
query
vs.//:query
difference. It really shouldn’t be different.Mayber after that I’ll have my head wrapped around what the better behaviour is.
You can get a similar failure even without
target_compatible_with
: