[build] document Bazel worktree output-base cleanup - #17689
Conversation
PR Summary by QodoDocument Bazel output-base cleanup for git worktrees Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
11 rules 1.
|
|
Code review by qodo was updated up to the latest commit a9b4d83 |
|
This would be better in the |
|
I like the idea, but I don't think we want to force this on everyone all the time. The output-base leak is specific to temporary worktrees on Mac/Linux. It would break things for Windows, and using a relative path can cause weird behaviors unless you always run bazel from top level directory. |
|
Code review by qodo was updated up to the latest commit 95c82b3 |
95c82b3 to
97cd919
Compare
|
merged part of this with #17756 because my memory is bad, this becomes just a readme update. |
| On macOS/Linux, make a worktree self-cleaning by pointing its output base inside the worktree. Add | ||
| this to that worktree's `.bazelrc.local`: | ||
|
|
||
| ``` | ||
| startup --output_base=.local/bazel-out | ||
| ``` |
There was a problem hiding this comment.
1. Unanchored output_base path 🐞 Bug ≡ Correctness
README recommends startup --output_base=.local/bazel-out, which is a relative path and can resolve differently depending on where Bazel is invoked from (e.g., from a subdirectory), creating multiple output bases and breaking the stated “output base lives under root .local/” cleanup behavior. This also means the output directory may not be covered by the repo’s .bazelignore entry (which only ignores the root .local).
Agent Prompt
## Issue description
`README.md` documents `startup --output_base=.local/bazel-out` for per-worktree cleanup. Because it’s a relative path, it may not consistently point at the workspace-root `.local/` directory, undermining the stated cleanup behavior and the repo’s `.bazelignore` assumptions.
## Issue Context
The repo already uses Bazel’s `%workspace%` expansion in `.bazelrc*` files, which provides a stable, workspace-root anchored path.
## Fix Focus Areas
- README.md[161-174]
## Proposed fix
Update the README snippet to use an anchored path, e.g.:
```
startup --output_base=%workspace%/.local/bazel-out
```
(Alternatively, explicitly state that Bazel must be invoked from the repo root for the relative path to work as intended, but the anchored form is more robust.)
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 97cd919 |
🔗 Related Issues
💥 What does this PR do?
Documents that Bazel creates a per-checkout output base that, unlike the shared
--disk_cache/--repository_cache, is never garbage-collected when a worktree is deleted. Inworktree-heavy workflows these orphaned output bases accumulate and leak gigabytes. The README
"Using Worktrees" section and AGENTS.md "Agent workspace" now explain how to make a worktree
self-cleaning by pointing its output base inside the worktree (
startup --output_base=.local/bazel-out),with a Windows caveat preserving the existing
--output_user_rootguidance.🔧 Implementation Notes
🤖 AI assistance
💡 Additional Considerations
🔄 Types of changes