--repository_cache is not inherited between build/fetch/sync
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the problem:
When configuring [`--repository_cache`](https://docs.bazel.build/versions/master/command-line-reference.html#flag--repository_cache) in `.bazelrc` one has to be careful to set it correctly to cover all cases where a fetch might occur. In particular, the following configuration will not cover the most common case of `bazel build`.
```
fetch --repository_cache=...
```
Instead, one has to configure it for all relevant commands:
```
build --repository_cache=...
fetch --repository_cache=...
sync --repository_cache=...
```
As of Bazel 3.1.0 `common --repository_cache=...` is also available. However, this fails on older versions, e.g. as of Bazel 2.1.1 it breaks commands like `bazel version`.
In contrast, Bazel will inherit `build` flags for commands like `test` or `coverage`. Would it be possible to also inherit flags like `--repository_cache` from `fetch` for `build` or `sync`?
If not that, the documentation of `--repository_cache` should at least clearly state how to configure the flag correctly in `.bazelrc`.
### what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Checkout https://github.com/aherrmann/repro-bazel-repository-cache-flag and execute the following command
```
$ ./repro.sh
```
It will try all combinations of configuring a repository cache and executing `build`, `fetch`, `sync` and check if the repository cache is created. It produces the following output:
```
# Testing `bazel build`
# Setting `build --repository_cache`
# CACHE FOUND
# Setting `fetch --repository_cache`
# NO CACHE
# Setting `sync --repository_cache`
# NO CACHE
# Testing `bazel fetch`
# Setting `build --repository_cache`
# NO CACHE
# Setting `fetch --repository_cache`
# CACHE FOUND
# Setting `sync --repository_cache`
# NO CACHE
# Testing `bazel sync`
# Setting `build --repository_cache`
# NO CACHE
# Setting `fetch --repository_cache`
# NO CACHE
# Setting `sync --repository_cache`
# CACHE FOUND
```
### What operating system are you running Bazel on?
Ubuntu 19.10
### What's the output of `bazel info release`?
release 3.1.0
Contributor guide
Research direction
Start with the .bazelrc flag configuration and run the referenced repro.sh script to compare repository-cache behavior for build, fetch, and sync. Determine whether command flag inheritance should change or whether the --repository_cache documentation should explain the required configuration, then verify the chosen behavior across the combinations shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100