recursive glob in top-level package follows "bazel-*" symlinks
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the problem:
A glob in the top-level package will follow the "bazel-*" convenience symlinks and pick up sources from them. I believe this is a regression of https://github.com/bazelbuild/bazel/issues/6350.
### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I can reproduce the problem with the following two files in my top level WORKSPACE directory.
**BUILD.bazel**
```
load("//:print_files.bzl", "print_files")
print_files(name="glob-defect", files_to_print=glob(["**/*"]))
```
**print_files.bzl**
```
def _print_files_impl(ctx):
print(ctx.label)
for file_to_print in ctx.attr.files_to_print:
print(file_to_print)
print_files = rule(
implementation = _print_files_impl,
attrs = {
'files_to_print' : attr.label_list(allow_files = True)
},
)
```
The first time I run in an new workspace everything looks fine (using the cpp-examples directory to test).
```
~/Code/examples/cpp-tutorial/stage1$ bazel build //...
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:3:10: //:glob-defect
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
INFO: Analyzed 2 targets (1 packages loaded, 5 targets configured).
INFO: Found 2 targets...
INFO: Elapsed time: 0.247s, Critical Path: 0.02s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
```
The next time I run Bazel has created the symlinks and will include them in the glob.
```
~/Code/examples/cpp-tutorial/stage1$ bazel build //...
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:3:10: //:glob-defect
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14:
INFO: Analyzed 2 targets (1 packages loaded, 21 targets configured).
INFO: Found 2 targets...
INFO: Elapsed time: 0.327s, Critical Path: 0.02s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
```
### What operating system are you running Bazel on?
Linux
### What's the output of `bazel info release`?
release 3.3.1
and also
release 3.4.0
### Have you found anything relevant by searching the web?
Previous bug of the same issue
https://github.com/bazelbuild/bazel/issues/6350
Contributor guide
Research direction
Reproduce the behavior with BUILD.bazel and print_files.bzl using glob(["**/*"]), then compare the first and subsequent bazel build outputs. Read the linked issue 6350 and trace the Bazel glob implementation from there; done means top-level recursive globs no longer include files reached through bazel-* convenience symlinks.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100