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

TreeArtifacts output directories aren't created with sandboxing enabled #6262

Closed
cushon opened this issue Sep 27, 2018 · 0 comments
Closed

Comments

@cushon
Copy link
Contributor

cushon commented Sep 27, 2018

With sandboxing enabled, Bazel doesn't create output directories for TreeArtifacts, and tools have to create them manually. The output directories should be created for consistency with other spawn strategies.

This issue was the underlying problem in #6203.

Repro:

BUILD

load(":def.bzl", "r")

r(name = "a")

def.bzl

def _r(ctx):
    d = ctx.actions.declare_directory("%s_dir" % ctx.label.name)
    ctx.actions.run_shell(
        outputs = [d],
        command = "cd %s && pwd" % d.path,
    )
    return [DefaultInfo(files = depset([d]))]

r = rule(implementation = _r)

Building with sandboxing enabled fails, because the directory for the TreeArtifact isn't created:

$ bazel build ...
...
ERROR: /tmp/tmp.wido4a1xyh/BUILD:3:1: error executing shell command: '/bin/bash -c cd bazel-out/k8-fastbuild/bin/a_dir && pwd' failed (Exit 1) bash failed: error executing command /bin/bash -c 'cd bazel-out/k8-fastbuild/bin/a_dir && pwd'

Use --sandbox_debug to see verbose messages from the sandbox

Building with --spawn_strategy=standalone succeeds:

bazel build --spawn_strategy=standalone ...
... OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants