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

use_extension fails with bzl from a repo introduced by use_repo_rule #22414

Open
laurentlb opened this issue May 16, 2024 · 2 comments
Open

use_extension fails with bzl from a repo introduced by use_repo_rule #22414

laurentlb opened this issue May 16, 2024 · 2 comments
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@laurentlb
Copy link
Contributor

Description of the bug:

My MODULE.bazel file looks like this:

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "config",
    ...)

repo_ext = use_extension("@config//:repo_ext.bzl", "repo_ext")
use_repo(repo_ext, "llvm")

I get the error: no repo visible as '@config' here.
My code builds if I use a local label (//:repo_ext.bzl instead of @config//:repo_ext.bzl).

Tested with Bazel 7.1, but it repros with USE_BAZEL_VERSION=last_green.

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

MacOS

What is the output of bazel info release?

release 7.1.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@Wyverald Wyverald added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. area-Bzlmod Bzlmod-specific PRs, issues, and feature requests labels May 16, 2024
@Wyverald Wyverald changed the title Repo declared with use_repo_rule not visible in MODULE.bazel use_extension fails with bzl from a repo introduced by use_repo_rule May 16, 2024
@Wyverald Wyverald added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels May 16, 2024
@fmeum
Copy link
Collaborator

fmeum commented May 23, 2024

Could you explain your use case for using extensions from non-module repos?

If this was allowed, repo rules could generate extension definitions. This has the disadvantage that it can become pretty complex on a conceptual level, but the advantage that it would potentially allow implementing isolated extension usages in "user space" (that's actually what I tried first before introducing isolate = True to use_extension).

@laurentlb
Copy link
Contributor Author

After chatting with @Wyverald, I've updated my code to use bazel_dep followed by archive_override. This works fine for me.

I'm still learning how to use the module system, it was not clear to me that http_archive wouldn't work.
Maybe the error message could be improved, or the documentation, or you can close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

No branches or pull requests

6 participants