Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Use of glob(**) in top-level BUILD.bazel breaks builds in dirty workspaces #11

Closed
jmillikin-stripe opened this issue Jun 29, 2017 · 3 comments

Comments

@jmillikin-stripe
Copy link

(copied/moved from google/subpar#29)

BUILD.bazel contains this target:

py_library(
   name = "containerregistry",
   srcs = glob(["**/*.py"]),
   deps = [ ... ]   
)

In a clean workspace, that glob picks up only the intended Python sources. But the build creates bazel-* symlinks, which are then detected by the glob and break later builds:

$ bazel clean
$ bazel build :pusher.par
INFO: Found 1 target...
Target //:pusher.par up-to-date:
  bazel-bin/pusher.par
INFO: Elapsed time: 1.992s, Critical Path: 0.54s
$ bazel build :pusher.par
INFO: Found 1 target...
ERROR: /Users/jmillikin/src/containerregistry/BUILD.bazel:36:1: Building par file //:pusher.par failed: I/O exception during sandboxed execution: /private/var/tmp/_bazel_jmillikin/165d82f9b8e48612b4a588f395fdde11/execroot/containerregistry/bazel-bin (No such file or directory).
Target //:pusher.par failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.503s, Critical Path: 0.06s

This can be fixed by using a more verbose glob over the directories you expect to exist:

py_library(
   name = "containerregistry",
   srcs = glob([
     "__init__.py",
     "client/**/*.py",
     "tools/**/*.py",
     "transform/**/*.py",
     "transport/**/*.py",
   ]), 

Another solution is to move the containerregistry target to a subdir, so it won't pick up stray build artifacts.

@mattmoor
Copy link
Contributor

We could probably add exclude=["bazel-*/**/*.py"] to the glob, but I'll go for the slightly less lazy enumeration you suggest. thanks again for spotting this.

@duggelz
Copy link

duggelz commented Jun 29, 2017

Can you also file a bug against Bazel itself? It's supposed to have logic to ignore these links for globbing, I believe.

@mattmoor
Copy link
Contributor

Yeah, I will open one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants