bazelbuild / bazelbuild/bazel

Mandatory output changes appear to have broken rules_rust where empty output directories are created

Open
#28,286 18 comments 0 reactions 0 assignees View on GitHub
awaiting-user-response P1 team-Remote-Exec type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

In rules_rust, we have an action which creates an output directory, but where that directory may be empty.

[We explicitly create this directory](https://github.com/bazelbuild/rules_rust/blob/cdaf15f5796e3e934b074526272823284bbaed01/cargo/private/cargo_build_script_runner/bin.rs#L58-L61) because, while most remote execution environments create declared output directories, some remote execution environments don't. But it is valid for this directory to not contain and files/directories.

Prior to 8.5.0 this worked fine. As of 8.5.0, we get errors due to mandatory outputs not being created:

```

(20:44:10) ERROR: /workdir/test/transitive_lib/BUILD.bazel:5:19: Running Cargo build script buildscript failed: (Exit 34): mandatory output test/transitive_lib/buildscript.out_dir was not created
--
java.io.IOException: mandatory output test/transitive_lib/buildscript.out_dir was not created
at com.google.devtools.build.lib.remote.RemoteExecutionService.downloadOutputs(RemoteExecutionService.java:1519)
at com.google.devtools.build.lib.remote.RemoteSpawnRunner.downloadAndFinalizeSpawnResult(RemoteSpawnRunner.java:508)
at com.google.devtools.build.lib.remote.RemoteSpawnRunner.lambda$exec$2(RemoteSpawnRunner.java:342)
at com.google.devtools.build.lib.remote.Retrier.execute(Retrier.java:245)
at com.google.devtools.build.lib.remote.RemoteRetrier.execute(RemoteRetrier.java:120)
at com.google.devtools.build.lib.remote.RemoteRetrier.execute(RemoteRetrier.java:109)
at com.google.devtools.build.lib.remote.RemoteSpawnRunner.exec(RemoteSpawnRunner.java:277)
at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:161)
...
 ```

### Which category does this issue belong to?

_No response_

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

Run rules_rust's RBE bazelci job which will fail fast.

You may need to revert https://github.com/bazelbuild/rules_rust/pull/3804 which pins our bazel version to work around this.

### Which operating system are you running Bazel on?

_No response_

### What is the output of `bazel info release`?

_No response_

### 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 HEAD` ?

```text

```

### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

I'm guessing this is https://github.com/bazelbuild/bazel/issues/27363 @fmeum

### Have you found anything relevant by searching the web?

_No response_

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by running the rules_rust RBE bazelci job and inspect RemoteExecutionService.downloadOutputs, where the reported failure occurs. Compare behavior before and after the suspected regression linked to issue 27363, then add coverage showing that a declared empty output directory is handled successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.