The Wayback Machine - https://web.archive.org/web/20211102181140/https://github.com/bazelbuild/bazel/issues/13950
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glob is unable to exclude recursive symlinks from evaluation #13950

Open
psigen opened this issue Sep 6, 2021 · 1 comment
Open

glob is unable to exclude recursive symlinks from evaluation #13950

psigen opened this issue Sep 6, 2021 · 1 comment

Comments

@psigen
Copy link
Contributor

@psigen psigen commented Sep 6, 2021

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
@janakdr
Copy link
Contributor

@janakdr janakdr commented Sep 9, 2021

cc @haxorz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment