finds.dev

mitsuhiko/self-replace

Utility library that helps to implement processes that replace themselves

View on GitHub

★ 820RustApache-2.0updated Apr 2026

// the take

A small Rust crate that solves one specific problem: replacing or deleting a running executable on Windows, where the OS normally locks the file. On Unix this is trivial; on Windows it requires a helper process trick, which is exactly what this crate encapsulates. Useful for any single-binary CLI tool that wants to ship self-update or self-uninstall.

The Windows implementation is the whole point — it spawns a helper process to do the rename/delete after the main process exits, handling the file-lock problem correctly. API surface is minimal: two functions, nothing more. From mitsuhiko (rye, Flask, Jinja), so the Windows edge cases are likely tested rather than guessed at. MSRV of 1.63 is low enough to not be a nuisance for most projects.

No rollback or verification — if the new binary is corrupt, `self_replace` just overwrites and you're stuck with a broken tool. No atomic replace on Windows (it uses a rename trick but a crash mid-swap can leave you with nothing). The crate is intentionally thin, so anything above 'overwrite the file' — signature verification, download with progress, version pinning — you have to wire up yourself. Star count is modest for how fundamental this problem is, suggesting most people either reinvent it or use the heavier `self_update` crate instead.

We read the README, the directory tree and a key source file in June 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
820
Forks
32
Language
Rust
License
Apache-2.0
Last commit
1 Apr 2026

// nearby

If self-replace isn't quite it.

All repos →