bazel does not like FIFOs

2024/02/05

Bazel does not like FIFOs

Perhaps obvious in retrospect, but it is not possible for a bazel build artifact to generate a named pipe in the filesystem.

The after-step checks will object if an output directory contains at least one.

I am not sure if this is accidental or not, but it kind of makes sense, since FIFOs are not hermetic, just as network connections are not hermetic.

You can see the error message that one of my build rules hit when attempting to create a FIFO.

╰─>$ bazel test //build/... --subcommands
Starting local Bazel server and connecting to it...
INFO: Deleting stale sandbox base /home/fmil/.cache/bazel/_bazel_fmil/97b05f79c6a3fe131672ed87a7f2c3b9/sandbox
DEBUG: /home/fmil/code/private-code-comments/build/rules.bzl:26:10: transitive:  [<source file tools/bash/runfiles/runfiles.bash>]
INFO: Analyzed target //build:first_test (144 packages loaded, 11719 targets configured).
SUBCOMMAND: # //build:first_test [action 'Action build/first_test.tmp.dir', configuration: c996bfa92bcafc2798baf4dbf854da936ce6f49485d19b67b34b429667416404, execution platform: @@local_config_platform//:host, mnemonic: Action]
(cd /home/fmil/.cache/bazel/_bazel_fmil/97b05f79c6a3fe131672ed87a7f2c3b9/execroot/_main && \
  exec env - \
  /bin/bash -c 'mkdir -p bazel-out/k8-fastbuild/bin/build/first_test.tmp.dir && mkfifo bazel-out/k8-fastbuild/bin/build/first_test.tmp.dir/first_test.fifo')
# Configuration: c996bfa92bcafc2798baf4dbf854da936ce6f49485d19b67b34b429667416404
# Execution platform: @@local_config_platform//:host
ERROR: /home/fmil/code/private-code-comments/build/BUILD.bazel:10:22: Error while validating output TreeArtifact File:[[<execution_root>]bazel-out/k8-fastbuild/bin]build/first_test.tmp.dir : Could not determine type of file for first_test.fifo under /home/fmil/.cache/bazel/_bazel_fmil/97b05f79c6a3fe131672ed87a7f2c3b9/execroot/_main/bazel-out/k8-fastbuild/bin/build/first_test.tmp.dir
ERROR: /home/fmil/code/private-code-comments/build/BUILD.bazel:10:22: Action build/first_test.tmp.dir failed: not all outputs were created or valid
Target //build:first_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 10.757s, Critical Path: 0.60s
INFO: 2 processes: 1 internal, 1 linux-sandbox.
ERROR: Build did NOT complete successfully
//build:first_test                                              FAILED TO BUILD

Executed 0 out of 1 test: 1 fails to build.