bazelbuild / bazelbuild/rules_pkg
Expose a Starlark library target for public pkg.bzl APIs
- Dominant language
- Starlark
- Stars
- 253
- Forks
- 221
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
Description
AI written, human reviewed.
## Problem
`rules_pkg` 1.3 still exports its public `.bzl` files, so ordinary `load()` calls continue to work. However, #1033 replaced `//pkg:bzl_srcs`, which provided `StarlarkLibraryInfo`, with the `//pkg:rules_pkg_lib` `filegroup`.
Downstream Starlark dependency tooling cannot use that filegroup as a `bzl_library` dependency. This affects tools that model the Starlark load graph, including Gazelle-generated `bzl_library` targets and lint/Stardoc analysis.
For example, a downstream file may contain:
```starlark
load("@rules_pkg//:pkg.bzl", "pkg_tar")
```
Gazelle generates a Starlark dependency for this load. With rules_pkg 1.2, `//pkg:bzl_srcs` could satisfy that dependency. With rules_pkg 1.3, `//pkg:rules_pkg_lib` is a plain `filegroup` and does not provide `StarlarkLibraryInfo`, producing an analysis error such as:
```text
does not produce any bzl_library deps files (expected .bzl or .scl)
```
## Expected behavior
A public target provides the Starlark provider for the supported `pkg.bzl` API, allowing downstream `bzl_library` targets to represent their load dependencies.
For example:
```starlark
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
bzl_library(
name = "pkg",
srcs = ["pkg.bzl"],
visibility = ["//visibility:public"],
)
```
The exact target name is not important if a documented public target is available. `//pkg:pkg` is useful because it matches Gazelle’s normal resolution of `//pkg:pkg.bzl`.
## Additional context
This is not a failure to export or load the `.bzl` files, and it does not affect normal rules_pkg execution. It is a tooling interoperability regression caused by removing the Starlark provider target in #1033.
I searched existing open and closed issues for `StarlarkLibraryInfo`, `bzl_srcs`, `starlark_library`, and Gazelle, but did not find an existing report.
Contributor guide
Research direction
Start by inspecting the definitions of //pkg:bzl_srcs and //pkg:rules_pkg_lib, then compare the provider behavior removed in #1033. Verify the documented public target can be used as a bzl_library dependency for a load of @rules_pkg//:pkg.bzl and that downstream analysis no longer reports a missing StarlarkLibraryInfo provider.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100