Skip to content

fix: do not break the root package when //gazelle is a package - #4530

Open
aignas wants to merge 2 commits into
bazel-contrib:mainfrom
aignas:fix.aignas.gazelle-downloader-glob
Open

aignas wants to merge 2 commits into
bazel-contrib:mainfrom
aignas:fix.aignas.gazelle-downloader-glob

Conversation

@aignas

@aignas aignas commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

The //:gazelle_downloader_configs filegroup referenced
gazelle/downloader_cfg.bazelrc and gazelle/downloader_config.cfg as
plain labels. That only works in the rules_python dev workspace, where
.bazelrc.deleted_packages disables //gazelle. When rules_python is used
as an external repository that contains gazelle/BUILD.bazel (e.g. via
git_override or local_path_override), these labels cross a package
boundary and are invalid, so loading any target in the root package fails:

ERROR: .../external/rules_python+/BUILD.bazel:89:10: Label '@@rules_python+//:gazelle/downloader_config.cfg' is invalid because '@@rules_python+//gazelle' is a subpackage; perhaps you meant to put the colon here: '@@rules_python+//gazelle:downloader_config.cfg'?

This becomes a blocker once every target depends on a root package target,
e.g. the default package_metadata added in #4276.

Use a glob with allow_empty = True instead. It does not cross package
boundaries, so it is empty for external users and still picks up the files in
the dev workspace, where //tests/dev:sync_downloader_configs_test consumes
them.

The `//:gazelle_downloader_configs` filegroup referenced
`gazelle/downloader_cfg.bazelrc` and `gazelle/downloader_config.cfg` as
plain labels. That only works in the rules_python dev workspace, where
`.bazelrc.deleted_packages` disables `//gazelle`. When rules_python is
used as an external repository that contains `gazelle/BUILD.bazel` (e.g.
via `git_override` or `local_path_override`), these labels cross a
package boundary and are invalid, so loading any target in the root
package fails, e.g. `@rules_python//:LICENSE`.

Use a `glob` with `allow_empty = True` instead. It does not cross
package boundaries, so it is empty for external users and still picks up
the files in the dev workspace.
@aignas
aignas requested a review from rickeylev as a code owner November 18, 2026 15:24
@aignas

aignas commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

This PR was prepared by an AI agent (Claude Code) at the request of @aignas. Review comments will be handled by @aignas, who reviews and approves any agent-generated responses or changes before they are posted.

This comment was generated by an AI agent and reviewed/approved by @aignas.

The gazelle filegroup now uses a glob, so the root BUILD.bazel no longer lists the synced file names for it. Point the sphinxdocs block at the sync script to keep the remaining pair checked.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant