Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to use @jq_toolchains//:resolved_toolchain when using bzlmod #689

Closed
mvgijssel opened this issue Dec 12, 2023 · 2 comments
Closed
Labels
bug Something isn't working untriaged Requires traige

Comments

@mvgijssel
Copy link

mvgijssel commented Dec 12, 2023

What happened?

I'm trying to implement

genrule(
    name = "case_genrule",
    srcs = ["a.json"],
    outs = ["genrule_output.json"],
    cmd = "$(JQ_BIN) '.' $(location a.json) > $@",
    toolchains = ["@jq_toolchains//:resolved_toolchain"],
)

inside a repository with bzlmod enabled (vgijssel/setup#616). Unfortunately I'm getting the following error:

(devbox) nix-shell-env ❯ bazel build //tools/bunq2ynab:hash
ERROR: /Users/maarten/Development/setup/tools/bunq2ynab/BUILD.bazel:169:8: no such package '@[unknown repo 'jq_toolchains' requested from @]//': The repository '@[unknown repo 'jq_toolchains' requested from @]' could not be resolved: No repository visible as '@jq_toolchains' from main repository and referenced by '//tools/bunq2ynab:hash'
ERROR: Analysis of target '//tools/bunq2ynab:hash' failed; build aborted: Analysis failed
INFO: Elapsed time: 2.528s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (6 packages loaded, 8 targets configured)

Version

Development (host) and target OS/architectures:

Output of bazel --version: bazel 6.4.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file: 2.0.3

How to reproduce

Create `MODULE.bazel` with


bazel_dep(name = "aspect_bazel_lib", version = "2.0.3")

Create BUILD.bazel with

genrule(
    name = "case_genrule",
    srcs = ["a.json"],
    outs = ["genrule_output.json"],
    cmd = "$(JQ_BIN) '.' $(location a.json) > $@",
    toolchains = ["@jq_toolchains//:resolved_toolchain"],
)
@mvgijssel mvgijssel added the bug Something isn't working label Dec 12, 2023
@github-actions github-actions bot added the untriaged Requires traige label Dec 12, 2023
@mvgijssel
Copy link
Author

Configuring the bazel_dep as follows seems to work

bazel_dep(name = "aspect_bazel_lib", version = "2.0.3")
bazel_lib_toolchains = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains")
bazel_lib_toolchains.jq()
use_repo(bazel_lib_toolchains, "jq_toolchains")

@thesayyn
Copy link
Collaborator

This is expected, bzlmod has strict visibility for repositories declared in other modules, you will have to do this unfortunately.

closing this as there's nothing to be fixed here.

@github-project-automation github-project-automation bot moved this to ✅ Done in Open Source May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Requires traige
Projects
None yet
Development

No branches or pull requests

2 participants