bazel-contrib / bazel-contrib/rules_oci

Bzlmod doesn't detect repo usage correctly

Open
#727 3 comments 3 reactions 0 assignees View on GitHub
bug need: discussion
Dominant language
Starlark
Stars
423
Forks
213
Avg merge
53m
Merged PRs (30d)
1

Description

When following the instructions from the [release](https://github.com/bazel-contrib/rules_oci/releases/tag/v2.0.1):

```starlark
bazel_dep(name = "rules_oci", version = "2.0.1")
# For testing, we also recommend https://registry.bazel.build/modules/container_structure_test

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")

# Declare external images you need to pull, for example:
oci.pull(
name = "distroless_base",
# 'latest' is not reproducible, but it's convenient.
# During the build we print a WARNING message that includes recommended 'digest' and 'platforms'
# values which you can use here in place of 'tag' to pin for reproducibility.
tag = "latest",
image = "gcr.io/distroless/base",
platforms = ["linux/amd64"],
)

# For each oci.pull call, repeat the "name" here to expose them as dependencies.
use_repo(oci, "distroless_base")
```

I get the following warning:
```
WARNING: REPO/MODULE.bazel:320:20: The module extension oci defined in @rules_oci//oci:extensions.bzl reported incorrect imports of repositories via use_repo():

Imported, but reported as indirect dependencies by the extension:
distroless_base

** You can use the following buildozer command to fix these issues:

buildozer 'use_repo_remove @rules_oci//oci:extensions.bzl oci distroless_base' //MODULE.bazel:all
```

When running `bazel mod tidy`, it adds `distroless_base_linux_amd64` which should not be necessary as `distroless_base` should be used instead (and this is also what I use in my `BUILD.bazel` files.

Contributor guide

Open the contributing guide

Research direction

Reproduce the warning using the MODULE.bazel snippet, then inspect @rules_oci//oci:extensions.bzl and the generated repository names after running `bazel mod tidy`. Compare the reported use_repo() imports with the distroless_base label used in BUILD.bazel files. Done means the expected repository is detected without adding distroless_base_linux_amd64.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.