`glob` is unable to exclude recursive symlinks from evaluation
#13,950 创建于 2021年9月6日
仓库指标
- Star
- (25,384 star)
- PR 合并指标
- (平均合并 22天 20小时) (30 天内合并 77 个 PR)
描述
Description of the problem / feature request:
glob throws an evaluation error when it detects an infinite recursion in a
directory traversal. However, it detects this recursion even if the specific
subpath leading to that recursion is excluded via the exclude=[] argument.
This means that recursive symlinks cannot be ignored in glob expressions, even if they occur in subtrees that bazel does not need to be evaluating.
It may also suggest that unnecessary directory tree evaluation is being performed when using glob expressions.
Consider the following structure:
.
├── BUILD.bazel
├── foo
│ ├── bar -> ../
│ └── payload.txt
└── WORKSPACE
The following glob expression will fail to evaluate, even though several wildcards
are provided to exclude=[] indicating that the foo/bar symlink doesn't need to be followed.
filegroup(
name = "broken",
srcs = glob(
include = ["**"],
exclude = [
"foo/bar",
"foo/bar*",
"foo/bar/**",
],
),
)
$ bazel build //:broken
INFO: Invocation ID: a302280d-4f28-4bcc-be3c-9cfe92159c6f
ERROR: infinite symlink expansion detected
[start of symlink chain]
/home/user/bazel-issue-13950
/home/user/bazel-issue-13950/foo/bar
[end of symlink chain]
ERROR: Skipping '//:broken': no such package '': Symlink issue while evaluating globs: Infinite symlink expansion: /home/user/bazel-issue-13950/foo/bar- > /home/user/bazel-issue-13950
WARNING: Target pattern parsing failed.
ERROR: no such package '': Symlink issue while evaluating globs: Infinite symlink expansion: /home/user/bazel-issue-13950/foo/bar- > /home/user/bazel-issue-13950
INFO: Elapsed time: 0.328s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I have created a minimal example here: https://github.com/psigen/bazel-issue-13950
What operating system are you running Bazel on?
Ubuntu 20.04
What's the output of bazel info release?
$ bazel info release
INFO: Invocation ID: e8c5b931-7292-4f74-a908-d496639b920d
release 4.2.1
Have you found anything relevant by searching the web?
I have not found references to this specific issue
- bugs around being unable to exclude subdirectories
- documentation indicating that this behavior is expected