-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cquery label outputs inconsistent after bazel 6 #17864
Comments
CC @Wyverald Getting rid of the bazel/src/main/java/com/google/devtools/build/lib/query2/cquery/StarlarkOutputFormatterCallback.java Line 191 in 7556e11
Having consistent stringification across cquery output modes is challenging with Bzlmod: In the interest of emitting human-readable labels, I implemented main repository mapping "unmapping" to the default output mode. This means that canonical repository names such as But in general Starlark code, the stringification of a label should always yield a canonical label string such as |
I've also seen @ vs @@ showing up as differences across linux vs. windows, within the same bazel version. |
That shouldn't be possible. (Or it's a bug that we need to fix.) In any case, the proper way to fix for this issue is unclear to me because of what @fmeum wrote above. The |
@Wyverald Can you triage this and reassign it to the correct label? |
team-Configurability isn't technically wrong since this is about cquery. But I'll keep an eye on this too. |
Looking into this again. Would anyone find it surprising if |
As noticed in bazel-contrib/rules_go#3659 (comment), there needs to be a way to match the output of Thus, instead of trying to force the main repo mapping into |
This sounds good to me. It's probably the least messy way to fix this... mess. |
If enabled, labels are emitted as if by the Starlark `str` function applied to a `Label` instance. This is useful for tools that need to match the output of different query commands and/or labels emitted by rules. If not enabled, output formatters are free to emit apparent repository names (relative to the main repository) instead to make the output more readable. This is implemented by replacing all `Label#toString()` calls in query code with an indirection through a `LabelPrinter` object constructed in a central place. There are currently three types of instances: * `canonical` behaves just like `str(Label(...))`; * `apparent` matches the current behavior, which renders main repo labels in repo-relative form and attempts to use the apparent names for external repos if possible; * `legacy` is used in all non-query callsites and uses `Label#toString()`. Fixes #17864 RELNOTES: The new `--consistent_labels` option on `query`, `cquery`, and `aquery` can be used to force consistent label formatting across all output modes that is also compatible with `str(Label(...))` in Starlark. Closes #19508. PiperOrigin-RevId: 566723654 Change-Id: Ifa08a82e281f423faa971c46bf7277cb307698b5
If enabled, labels are emitted as if by the Starlark `str` function applied to a `Label` instance. This is useful for tools that need to match the output of different query commands and/or labels emitted by rules. If not enabled, output formatters are free to emit apparent repository names (relative to the main repository) instead to make the output more readable. This is implemented by replacing all `Label#toString()` calls in query code with an indirection through a `LabelPrinter` object constructed in a central place. There are currently three types of instances: * `canonical` behaves just like `str(Label(...))`; * `apparent` matches the current behavior, which renders main repo labels in repo-relative form and attempts to use the apparent names for external repos if possible; * `legacy` is used in all non-query callsites and uses `Label#toString()`. Fixes #17864 RELNOTES: The new `--consistent_labels` option on `query`, `cquery`, and `aquery` can be used to force consistent label formatting across all output modes that is also compatible with `str(Label(...))` in Starlark. Closes #19508. PiperOrigin-RevId: 566723654 Change-Id: Ifa08a82e281f423faa971c46bf7277cb307698b5 --------- Co-authored-by: Fabian Meumertzheim <[email protected]>
A fix for this issue has been included in Bazel 6.4.0 RC1. Please test out the release candidate and report any issues as soon as possible. Thanks! |
Description of the bug:
It looks like in Bazel 6, in-repo labels started stringifying with a leading
@
.This is inconsistent with regular cquery output, which still doesn't have leading
@
s for labels:This means that if trying to filter cquery output based on some
--output=starlark
query expression (e.g. filtering out incompatible targets, as documented here), manual code needs to be written to add or strip a leading@
.It would seem useful for all cquery commands, and the native starlark label stringification, to use consistent stringification, so that simpler equality checks can be performed when processing the output.
The text was updated successfully, but these errors were encountered: