Better error when a `dev_dependency` mismatch happens between `use_extension` and `use_repo`
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the feature request:
When using the `llvm` extension as a `dev_dependency`, I forgot to also set `dev_dependency = True` in `use_repo` and I was getting a correct, although confusing visibility error:
```
ERROR: (...)/external/repro-toolchains_llvm_examples~/src/BUILD:3:10:
While resolving toolchains for target @@repro-toolchains_llvm_examples~//src:example (815f764):
invalid registered toolchain '@llvm_toolchain_system//:all':
No repository visible as '@llvm_toolchain_system' from repository '@@repro-toolchains_llvm_examples~'
ERROR: Analysis of target '//foo:example' failed; build aborted: Analysis failed
```
I [asked about the error] in Bazel's Slack and @fmeum kindly pointed me at my mistake 🙌.
It would be great if the mismatch was detected and it raised a different error that could point at the potential mistake.
P.S: repro repo: [jjmaestro/bazel_repro-toolchains_llvm_examples]
[asked about the error]: https://bazelbuild.slack.com/archives/CA31HN1T3/p1752505821512059
[jjmaestro/bazel_repro-toolchains_llvm_examples]: https://github.com/jjmaestro/bazel_repro-toolchains_llvm_examples
### Which category does this issue belong to?
_No response_
### What underlying problem are you trying to solve with this feature?
_No response_
### Which operating system are you running Bazel on?
_No response_
### What is the output of `bazel info release`?
_No response_
### 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` ?
```text
```
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start with the linked jjmaestro/bazel_repro-toolchains_llvm_examples repository and reproduce the mismatch between the llvm extension's dev_dependency setting and use_repo. Trace how Bazel reports the resulting visibility error, then define completion as a distinct diagnostic that points to the missing dev_dependency setting.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100