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

bzlmod using local repositories #196

Open
SimonVleugels opened this issue Oct 17, 2023 · 7 comments
Open

bzlmod using local repositories #196

SimonVleugels opened this issue Oct 17, 2023 · 7 comments

Comments

@SimonVleugels
Copy link

Hi,
I'm trying to use bazel-diff with bzlmod enabled using only local_repositories (no connection to bcr). I'm getting unknown repo errors:

ERROR: /repo/bazel-test-repo/BUILD.bazel:9:6: error loading package '@bazel_diff~override//cli': 
Unable to find package for @[unknown repo 'rules_jvm_external' requested from @bazel_diff~override]//:defs.bzl: 
The repository '@[unknown repo 'rules_jvm_external' requested from @bazel_diff~override]' could not be resolved: 
No repository visible as '@rules_jvm_external' from repository '@bazel_diff~override'. and referenced by '//:bazel-diff'

Bazel command:

./bazel-6.3.2 run \
--override_repository=bazel_diff=/repo/bazel-test-repo/build/bazel_diff \
--override_repository=io_bazel_rules_kotlin=/repo/bazel-test-repo/build/io_bazel_rules_kotlin \
--override_repository=rules_jvm_external=/repo/bazel-test-repo/build/rules_jvm_external \
--override_repository=rules_kotlin=/repo/bazel-test-repo/build/rules_kotlin \
--override_repository=rules_proto=/repo/bazel-test-repo/build/rules_proto \
--enable_bzlmod //:bazel-diff

Not sure what I'm doing wrong.

BUILD.bazel

alias(
    name = "bazel-diff",
    actual = "@bazel_diff//cli:bazel-diff",
)

MODULE.bazel

bazel_dep(name = "rules_proto")
local_path_override(
    module_name = "rules_proto",
    path = "/repo/bazel-test-repo/build/rules_proto",
)

bazel_dep(name = "bazel_skylib")
local_path_override(
    module_name = "bazel_skylib",
    path = "/repo/bazel-test-repo/build/bazel_skylib",
)

bazel_dep(name = "io_bazel_rules_kotlin")
local_path_override(
    module_name = "io_bazel_rules_kotlin",
    path = "/repo/bazel-test-repo/build/io_bazel_rules_kotlin",
)

bazel_dep(name = "rules_jvm_external")
local_path_override(
    module_name = "rules_jvm_external",
    path = "/repo/bazel-test-repo/build/rules_jvm_external",
)

bazel_dep(name = "bazel_diff")
local_path_override(
    module_name = "bazel_diff",
    path = "/repo/bazel-test-repo/build/bazel_diff",
)

WORKSPACE

#empty
@tinder-maxwellelliott
Copy link
Collaborator

I have not tested bazel-diff with bazelmod at all yet. I likely need to add support

@Venyi
Copy link

Venyi commented Feb 23, 2024

Hi, @tinder-maxwellelliott , any plan to test bzlmod?

@honnix
Copy link
Contributor

honnix commented Sep 13, 2024

Any plan to support bzlmod? Not entirely sure but I think we have seen bazel-diff not able to find any impacted targets for a bzlmod project. I can try to prepare a repro.

@honnix
Copy link
Contributor

honnix commented Sep 16, 2024

Any plan to support bzlmod? Not entirely sure but I think we have seen bazel-diff not able to find any impacted targets for a bzlmod project. I can try to prepare a repro.

I put up a repro here https://github.com/honnix/bazel-diff-bzlmod-repro.

It seems to be the --useCquery being problematic.

@honnix
Copy link
Contributor

honnix commented Sep 16, 2024

I did some debugging and I think the problem might boil down to the canonical repo name.

compatibleTargetSet here has @@//:BUILD.bazel, @@//:hello and @@//:hello.py, while cqueryResult here has //:BUILD.bazel, //:hello and //:hello.py instead.

The canonical repo name is one of the changes made in bzlmod as I remember I read it somewhere.

Found https://docs.google.com/document/d/1N81qfCa8oskCk5LqTW-LNthy6EBrDot7bdUsjz6JFC4/edit#heading=h.5mcn15i0e1ch

@honnix
Copy link
Contributor

honnix commented Sep 16, 2024

I did a naive hack cqueryResult.resultsList.filter { it.target.rule.name in compatibleTargetSet || "@@${it.target.rule.name}" in compatibleTargetSet }.map { it.target } and this could give the expected impacted target.

@honnix
Copy link
Contributor

honnix commented Sep 16, 2024

#224 might be a better fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants