Please provide the following information. The more we know about your system and use case, the more easily and likely we can help.
We have a glob intended to match all files and subdirectories of the current directory, something like
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
)
When subdirectories contain subpackages using a BUILD file, the glob does not match, as expected (and documented).
If a subpackage is delineated using the newer BUILD.bazel file, however, glob() seems to match files in that directory, causing build errors, since the matched files cross package boundaries, lots of errors like
W1129 20:39:45.042] ERROR: /workspace/k8s.io/test-infra/vendor/BUILD:3:12: Label '//vendor:github.com/bazelbuild/buildtools/CONTRIBUTING.md' crosses boundary of subpackage 'vendor/github.com/bazelbuild/buildtools' (perhaps you meant to put the colon here: '//vendor/github.com/bazelbuild/buildtools:CONTRIBUTING.md'?)
W1129 20:39:45.043] ERROR: /workspace/k8s.io/test-infra/vendor/BUILD:3:12: Label '//vendor:github.com/bazelbuild/buildtools/README.md' crosses boundary of subpackage 'vendor/github.com/bazelbuild/buildtools' (perhaps you meant to put the colon here: '//vendor/github.com/bazelbuild/buildtools:README.md'?)
W1129 20:39:45.048] ERROR: /workspace/k8s.io/test-infra/vendor/BUILD:3:12: Label '//vendor:github.com/bazelbuild/buildtools/build/syntax.go' crosses boundary of subpackage 'vendor/github.com/bazelbuild/buildtools/build' (perhaps you meant to put the colon here: '//vendor/github.com/bazelbuild/buildtools/build:syntax.go'?)
W1129 20:39:45.049] ERROR: /workspace/k8s.io/test-infra/vendor/BUILD:3:12: Label '//vendor:github.com/bazelbuild/buildtools/build/rule.go' crosses boundary of subpackage 'vendor/github.com/bazelbuild/buildtools/build' (perhaps you meant to put the colon here: '//vendor/github.com/bazelbuild/buildtools/build:rule.go'?)
W1129 20:39:45.049] ERROR: /workspace/k8s.io/test-infra/vendor/BUILD:3:12: Label '//vendor:github.com/bazelbuild/buildtools/status.sh' crosses boundary of subpackage 'vendor/github.com/bazelbuild/buildtools' (perhaps you meant to put the colon here: '//vendor/github.com/bazelbuild/buildtools:status.sh'?)
W1129 20:39:45.066] ERROR: /workspace/k8s.io/test-infra/vendor/BUILD:3:12: Label '//vendor:github.com/bazelbuild/buildtools/build/print.go' crosses boundary of subpackage 'vendor/github.com/bazelbuild/buildtools/build' (perhaps you meant to put the colon here: '//vendor/github.com/bazelbuild/buildtools/build:print.go'?)
Operating System:
Linux
Bazel version (output of bazel info release): release 0.8.0
First discovered by @mattmoor over in https://github.com/kubernetes/test-infra/pull/4859#issuecomment-347991032.
If a concrete repro case is desired I can probably create one. In the above linked PR, renaming vendor/github.com/bazelbuild/buildtools/BUILD.bazel, vendor/github.com/bazelbuild/buildtools/build/BUILD.bazel, and vendor/github.com/bazelbuild/buildtools/tables/BUILD.bazel fixed the build failure.
cc @BenTheElder
While working on #4056, I recently submitted 4117c867fe8e560f53bc1c7106af9c2889cc18f2, which fixes an error I had that looked suspiciously like this. That commit wasn't in the 0.8.0 release, could you please patch it in or test from HEAD and see if this issue is still happening?
Sure, I can try bazel from HEAD to see if it's fixed.
I also created https://github.com/ixdy/bazel/tree/recursive-glob-BUILD.bazel-failure which demonstrates the failure if you try to bazel build :bazel-srcs.tar.
yep, bazel-bin/src/bazel build :bazel-srcs.tar works, so I suspect this issue is already fixed.
Thanks for checking!
Is this in 0.9? Did it by chance land in 0.8.1? /cc @dslomov
it will not be in 0.8.1, I believe it is in 0.9.0rc1
Cool, thanks. I just wanted to know when I should poke the blocked PR.