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

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

Open
mcwilson07 opened this issue Jul 30, 2020 · 3 comments · May be fixed by #22128
Open

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

mcwilson07 opened this issue Jul 30, 2020 · 3 comments · May be fixed by #22128
Labels
not stale Issues or PRs that are inactive but not considered stale P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob type: bug

Comments

@mcwilson07
Copy link

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

@brandjon
Copy link
Member

Hm, that sure does seem problematic.

Anyone implementing this will want to note that 1) a symlink's name can be determined prior to the build, and 2) the set of symlinks is given by ConvenienceSymlinks#getStandardLinkDefinitions and any additional symlinks registered on ConfiguredRuleClassProvider.Builder#addSymlinkDefinition. It should in principle be possible to thread the set of symlink names through to PackageFunction / globbing logic.

(Note that I am not soliciting a PR at this time as I don't have the bandwidth.)

@brandjon brandjon added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Build-Language and removed team-Starlark untriaged labels Feb 19, 2021
@brandjon brandjon added team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob and removed team-Build-Language labels Nov 4, 2022
Copy link

github-actions bot commented Jan 9, 2024

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jan 9, 2024
@fmeum
Copy link
Collaborator

fmeum commented Jan 9, 2024

@bazelbuild/triage not stale

@brentleyjones brentleyjones added not stale Issues or PRs that are inactive but not considered stale and removed stale Issues or PRs that are stale (no activity for 30 days) labels Jan 9, 2024
@illicitonion illicitonion linked a pull request Apr 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not stale Issues or PRs that are inactive but not considered stale P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants