bazel-contrib / bazel-contrib/rules_oci
Can't use default name for oci.toolchains()
- Dominant language
- Starlark
- Stars
- 423
- Forks
- 213
- Avg merge
- 53m
- Merged PRs (30d)
- 1
Description
I am making use of the tarball as a base feature, and I saw that I had to register the regctl toolchains like so:
```
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.toolchains()
use_repo(oci, "oci_crane_toolchains", "oci_regctl_toolchains")
register_toolchains("@oci_crane_toolchains//:all", "@oci_regctl_toolchains//:all")
```
However, because `rules_oci` uses the default name, the root module can't use the default name and will fail like the following:
```
williamjen@xps-32:~/Documents/rules_oci_test$ cat MODULE.bazel
module(name = "rules_oci_test")
bazel_dep(name = "rules_oci", version = "2.2.6")
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.toolchains()
use_repo(oci, "oci_crane_toolchains", "oci_regctl_toolchains")
register_toolchains("@oci_crane_toolchains//:all", "@oci_regctl_toolchains//:all")
williamjen@xps-32:~/Documents/rules_oci_test$ bazel fetch
ERROR: /home/williamjen/.cache/bazel/_bazel_williamjen/496354c796d790eaf46341f4896da85f/external/rules_oci+/oci/repositories.bzl:124:27: Traceback (most recent call last):
File "/home/williamjen/.cache/bazel/_bazel_williamjen/496354c796d790eaf46341f4896da85f/external/rules_oci+/oci/extensions.bzl", line 69, column 36, in _oci_extension
oci_register_toolchains(toolchains.name, register = False)
File "/home/williamjen/.cache/bazel/_bazel_williamjen/496354c796d790eaf46341f4896da85f/external/rules_oci+/oci/repositories.bzl", line 117, column 30, in oci_register_toolchains
register_crane_toolchains(name, register = register)
File "/home/williamjen/.cache/bazel/_bazel_williamjen/496354c796d790eaf46341f4896da85f/external/rules_oci+/oci/repositories.bzl", line 124, column 27, in register_crane_toolchains
crane_repositories(
Error in repository_rule: A repo named oci_crane_darwin_amd64 is already generated by this module extension at /home/williamjen/.cache/bazel/_bazel_williamjen/496354c796d790eaf46341f4896da85f/external/rules_oci+/oci/repositories.bzl:124:27
ERROR: error evaluating module extension @@rules_oci+//oci:extensions.bzl%oci
Computing main repo mapping:
Fetching module extension @@rules_oci+//oci:extensions.bzl%oci; starting
williamjen@xps-32:~/Documents/rules_oci_test$
````
The easiest thing to do is to specify `oci.toolchains(name = "YOUR_CUSTOM_NAME")`. If this is the intended API, then we shouldn't let users use the default name. I think this is similar to https://github.com/aspect-build/rules_ts/issues/787
Edit: I am using Bazel 7.4.1 and the above repo was on 8.2.1.
Contributor guide
Assessment
This issue has not been assessed yet.