bazelbuild/bazel

Bazel resolved files are broken in 7.0.0

Open

#20,876 opened on Jan 12, 2024

View on GitHub
 (3 comments) (1 reaction) (0 assignees)Java (4,465 forks)batch import
P2help wantedteam-ExternalDepstype: bug

Repository metrics

Stars
 (25,384 stars)
PR merge metrics
 (Avg merge 22d 20h) (77 merged PRs in 30d)

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
int main() {
   return 0;
}
  • Add a BUILD
cc_binary(
    name="bin",
    srcs = ["main.c"],
)
  • Create a resolve.bzl
echo 'resolved = []' > resolve.bzl
  • Run sync
bazel sync --experimental_repository_resolved_file=resolve.bzl
  • Run a build
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 ?

?

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

Contributor guide