bzlmod doesn't exclude bazel-* from ellipsis by default in submodules
#24,190 创建于 2024年11月4日
仓库指标
- Star
- (25,384 star)
- PR 合并指标
- (平均合并 22天 20小时) (30 天内合并 77 个 PR)
描述
Description of the bug:
If you run bazel build ... in a root module it will by default exclude the standard symlink dirs that get created by bazel (bazel-bin, bazel-out, etc.). If you cd into a submodule and do this it will create the symlink dirs and will work fine there, but if you go back to the root module and try to build everything in a submodule (bazel build @submodule//...) it will likely fail because it will go into the bazel-out dirs that were created by running directly in the submodule and find many broken build files. Errors like
Unable to find package for @@[unknown repo]
Adding these bazel- dirs into .bazelignore in the submodule will cause it to behave as it does when bazel is called from under the directory of the submodule.
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.
Clone rules_python repo locally and cd into the directory in examples/bzlmod. Run this, should succeed
examples/bzlmod$ bazel build @our_other_module//...
cd into other_module and open the MODULE.bazel and uncomment the local_path_override. Build the other module from this dir
examples/bzlmod/other_module$ bazel build ...
cd back to the bzlmod dir and build @our_other_module//... again now, should error
examples/bzlmod$ bazel build @our_other_module//...
ERROR: infinite symlink expansion detected
[start of symlink chain]
.../execroot/_main/external/rules_python~
.../external/rules_python~
examples/bzlmod/other_module/bazel-other_module/external/rules_python~
[end of symlink chain]
ERROR: Infinite symlink expansion, for bazel-other_module/external/rules_python~, skipping: Infinite symlink expansion
WARNING: Target pattern parsing failed.
ERROR: Skipping '@our_other_module//...': error loading package under directory '': error loading package '@@other_module~//bazel-other_module/external/rules_python~~pip~other_module_pip/absl_py': Unable to find package for @@[unknown repo 'bazel_skylib' requested from @@other_module~]//lib:selects.bzl: The repository '@@[unknown repo 'bazel_skylib' requested from @@other_module~]' could not be resolved: No repository visible as '@bazel_skylib' from repository '@@other_module~'.
ERROR: error loading package under directory '': error loading package '@@other_module~//bazel-other_module/external/rules_python~~pip~other_module_pip/absl_py': Unable to find package for @@[unknown repo 'bazel_skylib' requested from @@other_module~]//lib:selects.bzl: The repository '@@[unknown repo 'bazel_skylib' requested from @@other_module~]' could not be resolved: No repository visible as '@bazel_skylib' from repository '@@other_module~'.
INFO: Elapsed time: 0.095s
INFO: 0 processes.
you can create a .bazelignore in the submodule with the following and the error will go away
bazel-bin
bazel-other_module
bazel-out
bazel-testlogs
Which operating system are you running Bazel on?
Ubuntu 24.04
What is the output of bazel info release?
release 7.3.1
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
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
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