Skip to content

Cached rules with directory outputs fail to build when build without the bytes is enabled #18579

@gabrielrussoc

Description

@gabrielrussoc

Description of the bug:

Rules outputting directories (which is not sane, but unfortunately happens) that hit the remote cache fail to build when build with the bytes is enabled.

I hit this when trying remote execution and it surprised me that tagging the genrule with no-remote-exec immediately fixes the issue, only to break a few builds later when the local outputs are gone and it starts to hit the remote cache. Note that this issue happens without remote execution at all.

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

Create a single BUILD file with:

genrule(
    name = "repro",
    outs = ["dir"],
    cmd = "mkdir $@; echo something > $@/a.txt",
)

build it:

$ bazel build --disk_cache=/tmp/bazel_disk_cache --remote_download_minimal //:repro

clear the local outputs:

$ bazel clean

build again (should hit the remote cache):

$ bazel build --disk_cache=/tmp/bazel_disk_cache --remote_download_minimal //:repro
...
ERROR: /Users/gabriel.russo/workspace/bazel_repro/BUILD:1:8: declared output 'dir' was not created by genrule. This is probably because the genrule actually didn't create this output, or because the output was a directory and the genrule was run remotely (note that only the contents of declared file outputs are copied from genrules run remotely)

Which operating system are you running Bazel on?

Linux and macOS

What is the output of bazel info release?

release 6.2.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions