Automatically clean up orphaned sandbox files on daemon startup
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the feature request:
Files in `~/.cache/bazel/_bazel_//sandbox/` that are not being used by an active Bazel process should be deleted on daemon startup.
### Which category does this issue belong to?
_No response_
### What underlying problem are you trying to solve with this feature?
Files in `~/.cache/bazel/_bazel_//sandbox/`, especially `sandbox/_moved_trash_dir/`, end up containing enormous amounts of temporary files that are not re-used from the cache. If bazel crashes, the daemon is force killed, or some undefined behavior occurs, these files are left on the host file system permanently until manually deleted. On my M.2 NVMe SSD running at up to 200MiB/s on ext4 fs it took over 45 minutes to delete all of it.
### Which operating system are you running Bazel on?
Bazzite 43, inside a stock Fedora distrobox
### What is the output of `bazel info release`?
release 9.0.1
### What's the output of `git remote get-url origin; git rev-parse HEAD` ?
```text
https://github.com/MulverineX/Moosync
e8aadcfe474e70861a00c96ca5e2ca33749a1cae
```
### Have you found anything relevant by searching the web?
- https://bazelbuild.slack.com/archives/CA31HN1T3/p1779044491470799
### Any other information, logs, or outputs that you want to share?
[find-log.tar.gz](https://github.com/user-attachments/files/27907128/find-log.tar.gz)
(I exited the `find` process early because it was stuck on `~/.cache/bazel/_bazel_//sandbox/` paths for a very long time)
Contributor guide
Assessment
This issue has not been assessed yet.