bazel: Regression in 3.5.0RC1: external repo with malformed WORKSPACE causes spurious errors

Description of the problem / feature request:

In the WORKSPACE file we have git_repository rule which pulls in another git repo. That git repo happens to have its own WORKSPACE file which is very old and is not correct for the recent versions of Bazel. Up until Bazel 3.4.1 that secondary WORKSPACE was rightfully completely ignored. Starting with the Bazel 3.5.0RC1 external WORKSPACE file seems to be analyzed for some reason and causes build errors.

Feature requests: what underlying problem are you trying to solve with this feature?

Accordingly to the docs only the primary WORKSPACE matters, all others should be ignored.

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Use git_repository to pull several years old com_google_protobuf. Its workspace file would not be correct from the recent Bazel point of view and cause errors, while it should be ignored.

What operating system are you running Bazel on?

Linux, Mac, Windows

What’s the output of bazel info release?

3.5.0RC1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (21 by maintainers)

Commits related to this issue

Most upvoted comments

I think we have a handle on the problem so we are going to try to fix forward and remove the unneeded parsing of the workspace. I have some tests I can try on Monday.

Could we revert to the previous behavior (for now) and ask @philwo’s team to investigate why WORKSPACE files are loaded?

@aiuto Here is what you asked for: https://github.com/Bazel-snippets/repro_11936 Secondary WORKSPACE file only contains the word garbage.

d:\dev\bazel\repro\repro_11936>bazel-3.4.1-windows-x86_64.exe  build hello-world
Starting local Bazel server and connecting to it...
INFO: Analyzed target //:hello-world (15 packages loaded, 62 targets configured).
INFO: Found 1 target...
Target //:hello-world up-to-date:
  bazel-bin/hello-world.exe
INFO: Elapsed time: 9.539s, Critical Path: 1.39s
INFO: 4 processes: 4 local.
INFO: Build completed successfully, 9 total actions

d:\dev\bazel\repro\repro_11936>bazel-3.5.0rc2-windows-x86_64.exe   build hello-world
Starting local Bazel server and connecting to it...
ERROR: C:/users/kerman/_bazel_kerman/beoihmbf/external/secondary_workspace/WORKSPACE:1:1: name 'garbage' is not defined
INFO: Analyzed target //:hello-world (16 packages loaded, 63 targets configured).
INFO: Found 1 target...
Target //:hello-world up-to-date:
  bazel-bin/hello-world.exe
INFO: Elapsed time: 9.006s, Critical Path: 0.06s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action

Despite the error the second build claims it is successful, so @michajlo is probably right that workspaces were always being analyzed but errors were ignored and/or lost until now