Repository navigation
--useCquery still drops main-repo aliases in WORKSPACE mode (follow-up to #612) - #622
Open
bala-evani-ai wants to merge 2 commits into
Open
bala-evani-ai wants to merge 2 commits into
bala-evani-ai wants to merge 2 commits into
Conversation
… under --useCquery Adds cquery_main_repo_alias_workspace, the cquery_main_repo_alias graph run with --noenable_bzlmod --enable_workspace, and an e2e case asserting that a change behind the alias reaches //:wrapper under --useCquery. It fails on master: in WORKSPACE mode main-repository labels print as @//, not @@//.
…ne form The Tinder#612 fix prefixed the apparent label repr() gives a main-repository alias (//:tool) with @@, the main repository's canonical form under Bzlmod. In WORKSPACE mode --consistent_labels prints main-repository targets as @//:tool, so @@//:tool still never matched, and the alias was dropped as if it were platform-incompatible, together with every edge through it. Compare the compatible-target labels through main_repo_label_key, which maps //x, @//x and @@//x to //x and leaves external labels alone, instead of guessing the prefix in the cquery formatter.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for the quick fix in #617! It works for Bzlmod, but WORKSPACE mode it doesn't and hit the same bug there: with
--useCquery, a change behind a main-repoaliasnever reaches the targets that use it.Repro
I added a WORKSPACE-mode copy of the #612 fixture (
cquery_main_repo_alias_workspace). It's the same//:wrapper→//:tool(alias) →//bar:bazgraph, plus aWORKSPACEfile and a.bazelrcwith--noenable_bzlmod --enable_workspace, likehub_spoke_external.With 74.0.1 on Bazel 8.8.2, after changing
bar/baz.txt://:tool,//:wrapper,//:wrapper.txt,//bar:baz,//bar:baz.txtare impacted, as expected--useCquery: only//bar:bazand//bar:baz.txt.//:toolisn't in the hash file at all.Why it still happens
#617 turns the alias name from
repr()(//:tool) into@@//:tool. That matches Bzlmod, where--consistent_labelsprints main-repo targets as@@//.... In WORKSPACE mode it prints them with a single@instead (@//:wrapper), so@@//:toolstill doesn't match and the alias gets filtered out as incompatible.Running
--consistent_labelswith a small Starlark formatter on the fixture shows it:All three forms (
//x,@//x,@@//x) refer to the same main-repo target; only the prefix differs by mode.The fix
Instead of guessing the prefix in the Starlark formatter, this compares labels with the main-repo prefix stripped. A new
main_repo_label_key()maps//x,@//xand@@//xto//xand leaves external labels alone. It's used both when building the compatible set and when checking targets against it. That's in line with howis_main_repo/main_repo_pathinsrc/hash.rsalready treat these.I looked at fixing it in Starlark instead, but
Label()isn't available in the cquery dialect, andtarget.labelon an alias gives you the actual target, not the alias.Tests
main_repo_alias_change_reaches_consumer_cquery_workspace_mode. It fails on master ("the alias //:tool was dropped from the cquery hashes") and passes with the fix.main_repo_label_key.cargo test --lib.fmtandclippyare clean.Like #617, the reproducer and the fix are separate commits.