bazelbuild / bazelbuild/bazel

check for dangling symlinks before copying outputs out of the sandbox

Open
#3,759 1 comment 0 reactions 1 assignee Claimed by @meisterT View on GitHub
not stale P3 team-Local-Exec type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

`SkyframeActionExecutor` raises an error if an action outputs a dangling symlink. The occurrence of this error may be non-deterministic for nonhermetic actions as this example shows:
```
$ cat BUILD
genrule(
name = 'make-target',
outs = ['target'],
cmd = "touch $@",
)

genrule(
name = 'make-link',
outs = ["link"],
cmd = "ln -s target $@",
)
$ bazel build :link
ERROR: BUILD:7:1: declared output 'link' is a dangling symbolic link.
ERROR: BUILD:7:1: not all outputs were created or valid.
$ bazel build :target
INFO: Found 1 target...
Target //:target up-to-date:
bazel-genfiles/target
INFO: Elapsed time: 0.206s, Critical Path: 0.04s
$ bazel build :link
INFO: Found 1 target...
Target //:link up-to-date:
bazel-genfiles/link
INFO: Elapsed time: 0.164s, Critical Path: 0.03s
```

It's unfortunate that the success of `:link` depends on whether `:target` has been built or not. The underlying problem is, of course, that `:make-link` is nonhermetic as it fails to declare `:target` as an input. This type of incorrectness could be deterministically flagged for sandboxed actions by checking for dangling symlinks before copying the outputs out of the sandbox execroot to the real execroot.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.