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 #6350

Closed
laszlocsomor opened this issue Oct 10, 2018 · 6 comments
Closed

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

laszlocsomor opened this issue Oct 10, 2018 · 6 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) type: bug

Comments

@laszlocsomor
Copy link
Contributor

Description of the problem / feature request:

A glob in the top-level package will follow the "bazel-*" convenience symlinks and pick up sources from them.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. git clone https://github.com/laszlocsomor/projects
  2. cd bazel/examples/glob_in_root_pkg
  3. bazel build -- just do a blank build so we have the "bazel-*" symlinks created
  4. bazel build //:x --spawn_strategy=standalone
  5. cat bazel-genfiles/x.txt

This builds happily on Windows, and the x.txt output will list not only "a.txt" but also files under "bazel-out".

On Linux, this fails at Step 4, but because the files under "bazel-out" are not inputs of the genrule action. However, it still shows that the glob picked up the files.

What operating system are you running Bazel on?

Linux / Windows 10

What's the output of bazel info release?

release 0.17.2
laszlocsomor added a commit to laszlocsomor/projects that referenced this issue Oct 10, 2018
@irengrig irengrig added team-Starlark untriaged P1 I'll work on this now. (Assignee required) labels Oct 11, 2018
@laurentlb laurentlb added team-Bazel General Bazel product/strategy issues and removed team-Starlark labels Oct 14, 2018
@jin jin removed the untriaged label Nov 5, 2018
@laszlocsomor
Copy link
Contributor Author

@laurentlb : Do you have any updates on this bug? Is P1 appropriate? Is this something to fix before Bazel 1.0?

@laurentlb laurentlb removed their assignment Feb 21, 2019
@laurentlb
Copy link
Contributor

I think it should be triaged.

@dslomov dslomov added team-Starlark and removed team-Bazel General Bazel product/strategy issues labels Jul 5, 2019
@dslomov
Copy link
Contributor

dslomov commented Jul 5, 2019

Who owns glob() implementation? team-Starlark or team-Core? cc @laurentlb @ericfelly

@laszlocsomor
Copy link
Contributor Author

I've been working on glob() recently, I could look at this.

@laszlocsomor
Copy link
Contributor Author

This seems to be fixed in Bazel 0.28.1.

@mcwilson07
Copy link

mcwilson07 commented Jul 30, 2020

I believe this has regressed at some point. I can reproduce the problem with the following two files in my top level WORKSPACE directory. I have reproduced it on 3.3.1 and 3.4.0 but haven't gone back further.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) type: bug
Projects
None yet
Development

No branches or pull requests

6 participants