Utility library that helps to implement processes that replace themselves
Rust
824
62 commits
updated Apr 1, 2026
self-replace is a crate that allows binaries to replace themselves with newer
versions or to uninstall themselves. On Unix systems this is a simple feat, but
on Windows a few hacks are needed which is why this crate exists.
This is a useful operation when working with single-executable utilties that want to implement a form of self updating or self uninstallation.
For details about the implementation refer to the documentation.
If you are looking for some higher level update logic, have a look at
self_update which uses self-replace
under the hood but provides automatic updating from GitHub releases or
other distribution channels. Note that self_update is maintained by
other maintainers.
To uninstall a binary, use self_delete.
self_replace::self_delete()?;
To replace a binary for updating, use self_replace.
let new_binary = "/path/to/new/binary";
self_replace::self_replace(&new_binary)?;
std::fs::remove_file(&new_binary)?;
(top 24 of 37)
1,755 followers · starred May 2023
7,868 followers · starred May 2023
5,066 followers · starred Mar 2025
1,154 followers · starred Jun 2024
Utility library that helps to implement processes that replace themselves
Rust
824
62 commits
updated Apr 1, 2026
self-replace is a crate that allows binaries to replace themselves with newer
versions or to uninstall themselves. On Unix systems this is a simple feat, but
on Windows a few hacks are needed which is why this crate exists.
This is a useful operation when working with single-executable utilties that want to implement a form of self updating or self uninstallation.
For details about the implementation refer to the documentation.
If you are looking for some higher level update logic, have a look at
self_update which uses self-replace
under the hood but provides automatic updating from GitHub releases or
other distribution channels. Note that self_update is maintained by
other maintainers.
To uninstall a binary, use self_delete.
self_replace::self_delete()?;
To replace a binary for updating, use self_replace.
let new_binary = "/path/to/new/binary";
self_replace::self_replace(&new_binary)?;
std::fs::remove_file(&new_binary)?;
(top 24 of 37)
1,755 followers · starred May 2023
7,868 followers · starred May 2023
5,066 followers · starred Mar 2025
1,154 followers · starred Jun 2024