-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Reference invisible bzlmod repos from command line #18543
Description
Description of the feature request:
It's impossible to request to build a repo that isn't visible directly on the command-line. While this isn't something suitable for production code, it's very useful for debugging module extensions.
As this isn't suitable for production, I would expect it to probably be blocked behind a flag, similar to --nocheck_visibility. Something along the lines of being able to run:
bazel build --nocheck_repo_visibility @module~version~repo//:foobazel query --nocheck_repo_visibility 'deps(@module~version~repo//:foo)'
Note that I'd only expect to be able to do this from the command-line, and not from inside a build file.
What underlying problem are you trying to solve with this feature?
It's very hard to debug failures coming from module extensions. Consider the following example from my personal experience:
$ bazel build //bazel/ebuild/private/cmd/build_package:build_package_test
INFO: Analyzed target //bazel/ebuild/private/cmd/build_package:build_package_test (0 packages loaded, 381 targets configured).
INFO: Found 1 target...
ERROR: /usr/local/google/home/msta/.cache/bazel/_bazel_msta/ed8a9562ed8b7b4d013265ed31cbccd4/external/rules_rust~0.20.1~crate~cros_crates_alchemy__proc-macro-error-attr-1.0.4/BUILD.bazel:22:16: Compiling Rust proc-macro proc_macro_error_attr v1.0.4 (4 files) [for tool] failed: (Exit 1): process_wrapper failed: error executing command (from target @rules_rust~0.20.1~crate~cros_crates_alchemy__proc-macro-error-attr-1.0.4//:proc_macro_error_attr) bazel-out/k8-opt-exec-C69D840F/bin/external/rules_rust~0.20.1/util/process_wrapper/process_wrapper --env-file ... (remaining 48 arguments skipped)
I can see in the output from target @rules_rust~0.20.1~crate~cros_crates_alchemy__proc-macro-error-attr-1.0.4//:proc_macro_error_attr. At this point, I'd like to determine how I depend on that target, so I run bazel query 'somepath(//bazel/ebuild/private/cmd/build_package:build_package_test, @rules_rust~0.20.1~crate~cros_crates_alchemy__proc-macro-error-attr-1.0.4//:proc_macro_error_attr)'. However, when I do so, I get ERROR: No repository visible as '@rules_rust~crate~cros_crates_alchemy__proc-macro-error-attr-1.0.4' from main repository.
Obviously, I can get around this by adding use_repo to the MODULE.bazel, but it'd be really nice if, in general, the bazel command line was able to build targets from repos that aren't visible.
Which operating system are you running Bazel on?
Linux
What is the output of bazel info release?
release 6.2.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 master; git rev-parse HEAD ?
N/A
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response