bazelbuild/bazel

bzlmod doesn't exclude bazel-* from ellipsis by default in submodules

Open

#24.190 aperta il 4 nov 2024

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)Java (4465 fork)batch import
P2area-Bzlmodhelp wantedteam-ExternalDepstype: bug

Metriche repository

Star
 (25.384 star)
Metriche merge PR
 (Merge medio 22g 20h) (77 PR mergiate in 30 g)

Descrizione

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

Guida contributor