-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Description of the bug:
I have custom rules that create symlinks that at the time of the build are intentionally broken links that are then fed into another rule that composes them into an artifact where the links are valid. I'm trying to upgrade to Bazel 6.3.0 and am running into the following error when I get remote cache hits using --remote_download_toplevel.
ERROR: /Users/User/Code/directory_bug/BUILD.bazel:9:14: Error while validating output TreeArtifact File:[[<execution_root>]bazel-out/darwin_arm64-fastbuild/bin]directory_bug : Failed to resolve relative path symlink_directory inside TreeArtifact /private/var/tmp/_bazel_user/68b71d322ac1da8a4878040e6895dbc8/execroot/directory_bug/bazel-out/darwin_arm64-fastbuild/bin/directory_bug. The associated file is either missing or is an invalid symlink.
ERROR: /Users/User/Code/directory_bug/BUILD.bazel:9:14: Action directory_bug failed: not all outputs were created or valid
This did not occur on Bazel 6.2.1. Is there an incompatibility flag that I can use to restore the previous behavior?
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.
Using the following workspace, I'm able to build on Bazel 6.3.0 with a remote cache configured to see the bug. Building on Bazel 6.2.1 does not observe the issue.
| shasum | file |
|---|---|
e430bf04f9d2e5e4a3a82f54993514d05d4224b2decf65b353175f0fb1bc2a3a |
directory_bug.zip |
.bazelrc
build --remote_download_toplevel
BUILD.bazel
load("//:defs.bzl", "directory_bug")
sh_binary(
name = "action",
srcs = ["action.sh"],
visibility = ["//visibility:public"],
)
directory_bug(
name = "directory_bug",
)action.sh
#!/usr/bin/env bash
set -euo pipefail
OUT_DIR="${OUT_DIR}"
mkdir -p "${OUT_DIR}/a"
touch "${OUT_DIR}/a/a.txt"
ln -s a "${OUT_DIR}/symlink_directory"
mkdir -p "${OUT_DIR}/symlink"
ln -s ../a "${OUT_DIR}/symlink/relative"defs.bzl
"""Example"""
def _directory_bug_impl(ctx):
out_dir = ctx.actions.declare_directory(ctx.label.name)
ctx.actions.run(
outputs = [out_dir],
executable = ctx.executable._executable,
env = {
"OUT_DIR": out_dir.path,
}
)
return [DefaultInfo(files = depset([out_dir]))]
directory_bug = rule(
implementation = _directory_bug_impl,
attrs = {
"_executable": attr.label(
executable = True,
cfg = "exec",
default = Label("//:action"),
)
}
)Which operating system are you running Bazel on?
Linux, MacOS
What is the output of bazel info release?
release 6.3.0
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.
This is a regression but I do not know the commit it was produced on.
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response