bazel: Breaking change in Bazel CQuery due to Starlarkification of providers
Description of the bug:
The following cquery no longer works with Bazel 7:
bazel cquery "@bazel_tools//tools/jdk:current_java_toolchain" --output starlark --starlark:expr 'providers(target)["JavaToolchainInfo"].source_version'
It looks like that providers(target)["JavaToolchainInfo"] needs to be replaced with providers(target)['@@_builtins//:common/java/java_toolchain.bzl%JavaToolchainInfo'].source_version but it feels odd to require this verbosity now. Especially the label syntax looks subjective to further changes. It should be possible to select a provider without relying on the location.
What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
echo "7.0.0.rc5" > .bazelversion
run the query
Have you found anything relevant by searching the web?
Any other information, logs, or outputs that you want to share?
This needs to be documented. Ideally all those queries would continue to work, though.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (14 by maintainers)
Thanks @hvadehra. Using
--starlark:fileworks much better for this.Oh, that looks doable.
BTW, that example doc needs fixing as well:
It should mention the specifics around keys instability from Bazel version to version.
Is it necessary for the starlark code to be specified on the command line? If not, you could use
--starlark:fileinstead. There are examples in the docs.Thanks for confirming!
Please do!