Skip to content

recursive glob in top-level package follows "bazel-*" symlinks #11875

@mcwilson07

Description

@mcwilson07

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 #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: <input file target //:BUILD.bazel>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:README.md>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:WORKSPACE>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:print_files.bzl>
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: <input file target //:BUILD.bazel>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:README.md>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:WORKSPACE>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-bin/main/_objs/hello-world/hello-world.pic.d>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-bin/main/_objs/hello-world/hello-world.pic.o>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-bin/main/hello-world>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-bin/main/hello-world-2.params>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-bin/main/hello-world.runfiles/MANIFEST>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-bin/main/hello-world.runfiles/__main__/main/hello-world>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-bin/main/hello-world.runfiles_manifest>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-out/k8-fastbuild/bin/main/_objs/hello-world/hello-world.pic.d>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-out/k8-fastbuild/bin/main/_objs/hello-world/hello-world.pic.o>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-out/k8-fastbuild/bin/main/hello-world>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-out/k8-fastbuild/bin/main/hello-world-2.params>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-out/k8-fastbuild/bin/main/hello-world.runfiles/MANIFEST>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-out/k8-fastbuild/bin/main/hello-world.runfiles/__main__/main/hello-world>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-out/k8-fastbuild/bin/main/hello-world.runfiles_manifest>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-out/stable-status.txt>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:bazel-out/volatile-status.txt>
DEBUG: examples/cpp-tutorial/stage1/print_files.bzl:5:14: <input file target //:print_files.bzl>
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
#6350

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)not staleIssues or PRs that are inactive but not considered staleteam-Loading-APIBUILD file and macro processing: labels, package(), visibility, globtype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions