Bazel resolved files are broken in 7.0.0
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
`--experimental_repository_resolved_file` and `--experimental_resolved_file_instead_of_workspace` are no longer able to build a simple application with Bazel 7.0.0. `bazel sync` completes without error, but upon trying to build with the resolve.bzl, I get the following error related to toolchains. The same steps succeed with Bazel 6.4.0.
```
(12:24:16) INFO: Current date is 2024-01-12
(12:24:17) ERROR: /tmp/bzl-resolve/BUILD:1:10: While resolving toolchains for target //:bin (5b7f3da): invalid registered toolchain '//toolchains:all': while parsing '//toolchains:all': no such package 'toolchains': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
- /tmp/bzl-resolve/toolchains
(12:24:17) ERROR: Analysis of target '//:bin' failed; build aborted
(12:24:17) INFO: Elapsed time: 0.458s, Critical Path: 0.01s
(12:24:17) INFO: 1 process: 1 internal.
(12:24:17) ERROR: Build did NOT complete successfully
(12:24:17) FAILED:
Fetching repository @@local_jdk; starting
```
### Which category does this issue belong to?
Core, External Dependency, Local Execution
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
* Create an empty `WORKSPACE`
* Add a `main.c`
```c
int main() {
return 0;
}
```
* Add a `BUILD`
```py
cc_binary(
name="bin",
srcs = ["main.c"],
)
```
* Create a `resolve.bzl`
```sh
echo 'resolved = []' > resolve.bzl
```
* Run sync
```sh
bazel sync --experimental_repository_resolved_file=resolve.bzl
```
* Run a build
```sh
bazel build //:bin --experimental_resolved_file_instead_of_workspace=resolve.bzl
```
### Which operating system are you running Bazel on?
Ubuntu 22.04 (WSL2)
### What is the output of `bazel info release`?
release 7.0.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` ?
```text
?
```
### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
Yes, 6.4.0 is working.
### Have you found anything relevant by searching the web?
No, there's very little discussion of resolve files in general.
### Any other information, logs, or outputs that you want to share?
gzipped resolve.bzl from 7.0.0 (since Github won't allow a direct upload)[resolve.bzl.gz](https://github.com/bazelbuild/bazel/files/13922370/resolve.bzl.gz)
Contributor guide
Research direction
Reproduce the regression with the empty WORKSPACE, main.c, BUILD, and resolve.bzl files using the supplied bazel sync and bazel build commands. Compare the resolved toolchain handling in Bazel 7.0.0 with 6.4.0, then verify that the minimal application builds with the resolved file while preserving the existing 6.4.0 behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, ubuntu
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100