bazelbuild / bazelbuild/bazel

Option to use copies of input files rather than symlinks in genrule, sh_test, etc

Open
#18,383 5 comments 9 reactions 0 assignees View on GitHub
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

### Description of the feature request:

Some tools (such as Docker) work differently when a file is symlink rather than just the file.

Bazel creates symlinks as an optimization, but sometimes this changes the behaviour of the rule.

Bazel should provide the option to disable symlinks and copy the files on a rule-basis.

```starlark
sh_test(
name = "test",
srcs = [ "test.sh" ],
args = [
"$(location :docker-compose.yaml)",
],
data = [
"docker-compose.yaml",
],
# Input files will be copied into the sandbox rather than placed as symlinks
disable_sandbox_symlinks = True, # Defaults to false, so this is a non-breaking change
)
```

### What underlying problem are you trying to solve with this feature?

Make it easier to work with tools from Bazel.

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

Linux

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

release 5.4.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` ?

```text
N/A
```

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

Maybe related: https://github.com/bazelbuild/bazel/issues/4320

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by investigating Bazel's sandbox input materialization for genrule and sh_test, especially how data and $(location) inputs are placed. The feature would be complete when a rule-level option causes input files to be copied rather than symlinked without changing the default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.