finds.dev← search

// the find

mitsuhiko/self-replace

★ 820 · Rust · Apache-2.0 · updated Apr 2026

Utility library that helps to implement processes that replace themselves

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.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →