bzlmod migration of a repo with `local_repository` child

99 views
Skip to first unread message

Menny Even Danan

unread,
Aug 10, 2025, 11:29:52 AMAug 10
to bazel-discuss
Hey all.
I am trying to migrate to bzlmod a large codebase that one of its Bazel dependency is another (internal) local_repository.
Basically, the structure is:
```
/WORKSPACE: local_repository("inner", path="inner")
/inner/WORKSPACE
```
I have an example of this structure in this (`main` branch) git repo: https://github.com/menny/bzlmod-playground

Both repositories have a lot of dependencies so we want to do to an incremental migration with the hybrid approach (introducing `MODULE.bazel` file and keep non-migrated deps in `WORKSAPCE.bzlmod` file).
When moving to the hybrid setup in the `inner` project, it builds just fine by itself - from its folder - but when trying to access the `inner` from the root workspace, things break: essentially, any dependency that is declared in the `WORKSPACE.bzlmod` file will not be visible to the `inner` workspace from the root scope, with the error:
```
ERROR: Skipping '@inner//...': error loading package under directory '': error loading package '@@inner+//src/main/java/com/example': Unable to find package for @@[unknown repo 'aspect_bazel_lib' requested from @@inner+]//lib:copy_to_bin.bzl: The repository '@@[unknown repo 'aspect_bazel_lib' requested from @@inner+]' could not be resolved: No repository visible as '@aspect_bazel_lib' from repository '@@inner+'.
ERROR: error loading package under directory '': error loading package '@@inner+//src/main/java/com/example': Unable to find package for @@[unknown repo 'aspect_bazel_lib' requested from @@inner+]//lib:copy_to_bin.bzl: The repository '@@[unknown repo 'aspect_bazel_lib' requested from @@inner+]' could not be resolved: No repository visible as '@aspect_bazel_lib' from repository '@@inner+'.
```
See an example in the same git repo (under the `hybrid-761` branch): https://github.com/menny/bzlmod-playground/tree/hybrid-761

Any suggestions on how to overcome this issue?

Thank you.

zhang kai

unread,
Aug 18, 2025, 4:32:56 AMAug 18
to bazel-discuss
We overcome this by putting all the local_repository into a inner bazel registry and use this registry in all our bazel repos.

Menny Even Danan

unread,
Aug 18, 2025, 5:11:01 PMAug 18
to bazel-discuss
I've tried using `local_path_override`. Are you saying that using an internal bazel registry will use the _hybrid_ WORKSPACE.bzlmod file?
Reply all
Reply to author
Forward
0 new messages