Skip to content

feat(cli,daemon): relocate daemon exe to global runtime-binaries dir - #158

Merged
zackees merged 1 commit into
mainfrom
fix/issue-134-runtime-binaries
May 10, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/issue-134-runtime-binaries

Conversation

@zackees

@zackees zackees commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Closes #134. Implements the design from #134 (comment).

Summary

  • CLI `prepare_daemon_exe()` copies the daemon binary from its install path (e.g. `Scripts/zccache-daemon.exe`) to `<global_cache_dir>/runtime-binaries/zccache-daemon..` and the CLI spawns from that copy. The install path is never executed in place, so `pip install --upgrade zccache` always works.
  • `gc_runtime_binaries()` runs on every spawn — `fs::remove_file` on every entry. Locked files (live daemons) are silently skipped by the OS, so no PID tracking or sidecar files are needed.
  • Daemon `unlock_exe()` short-circuits when `current_exe()` lives under `runtime-binaries/`. It remains as a fallback for direct invocations of `zccache-daemon.exe`.
  • README rewritten to document the two-layer flow + `ZCCACHE_NO_UNLOCK` opt-out.

Test plan

  • 4 new unit tests in `zccache-cli`: `prepare_daemon_exe_in_copies_to_target_dir`, `prepare_daemon_exe_in_creates_missing_dest_dir`, `gc_runtime_binaries_in_removes_unlocked_entries`, `gc_runtime_binaries_in_is_noop_for_missing_dir` — all pass.
  • New `crates/zccache-daemon/tests/exe_overwrite.rs` (Windows-only) validates the daemon's fallback in-place rename path — passes.
  • `soldr cargo clippy --workspace --all-targets -- -D warnings` clean.
  • `soldr cargo fmt --all -- --check` clean.
  • Existing `tests/cwd_release.rs` regression unchanged.

🤖 Generated with Claude Code

Closes #134.

Refines the lock-avoidance design from PR #135. The previous in-place
`unlock_exe()` left `.old.<rand>` siblings next to the canonical exe
(e.g. `Scripts/zccache-daemon.exe.old.123`), which clutters the Python
install location and makes GC awkward.

New flow:

1. CLI's `prepare_daemon_exe()` copies the daemon binary from its install
   path into `<global_cache_dir>/runtime-binaries/zccache-daemon.<rand>.<ext>`
   before spawning. The install path is never executed in place, so
   `pip install --upgrade zccache` always works.
2. `gc_runtime_binaries()` runs on every spawn — `fs::remove_file` on
   every entry. Locked files (live daemons) are silently skipped by the
   OS, so no PID tracking or sidecar files are needed.
3. Daemon's `unlock_exe()` short-circuits when `current_exe()` lives
   under `runtime-binaries/`. It remains as a fallback for direct
   invocations of `zccache-daemon.exe`.

Tests:
- 4 unit tests in `zccache-cli`: copy + create-missing-dir + GC happy
  path + GC missing-dir no-op.
- Existing `tests/exe_overwrite.rs` (Windows-only) still validates the
  daemon's fallback in-place rename path.

Documentation: rewrote `crates/zccache-daemon/README.md` to describe the
two-layer flow and the `ZCCACHE_NO_UNLOCK` opt-out.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 3319e8e into main May 10, 2026
18 of 20 checks passed
zackees added a commit that referenced this pull request May 11, 2026
Patch bump covering everything merged since v1.4.0:

- fix(daemon,ci): tolerate unknown sessions and stop killing soldr's
  daemon (#168, closes #166 + #167)
- feat(cli): expose session_end_idempotent for all daemon callers (#163)
- fix(daemon): deterministic flush primitive for event log (#162)
- feat(cli,daemon): relocate daemon exe to global runtime-binaries dir (#158)
- fix(depgraph): normalize workspace-path inputs out of rustc cache key (#160)
- perf(ci): trim platform Test, drop --all-targets from Check, split
  Test/Check jobs (#161, #164, #165)
- chore(ci): drop invalid target-cache-paths from build-target action (#157)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the fix/issue-134-runtime-binaries branch November 5, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

daemon spawn inherits caller cwd in non-wrapper paths (pins .venv on Windows)

1 participant