#replace #uninstall #self-update #self-uninstall

self-replace

Utility crate that allows executables to replace or uninstall themselves

10 stable releases

1.3.7 Sep 19, 2023
1.3.6 Aug 25, 2023
1.3.5 Jun 3, 2023
1.3.3 May 19, 2023

#78 in Unix APIs

Download history 12910/week @ 2024-01-02 13646/week @ 2024-01-09 19555/week @ 2024-01-16 18732/week @ 2024-01-23 17624/week @ 2024-01-30 23049/week @ 2024-02-06 17727/week @ 2024-02-13 17867/week @ 2024-02-20 19340/week @ 2024-02-27 19354/week @ 2024-03-05 18054/week @ 2024-03-12 19721/week @ 2024-03-19 17076/week @ 2024-03-26 18093/week @ 2024-04-02 17733/week @ 2024-04-09 15212/week @ 2024-04-16

71,877 downloads per month
Used in 44 crates (7 directly)

Apache-2.0

26KB
281 lines

Self-Replace: A Utility For Self Replacing Executables

Build Status Crates.io License rustc 1.48.0 Documentation

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.

Uninstall

To uninstall a binary, use self_delete.

self_replace::self_delete()?;

Updating

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)?;

Dependencies

~2–14MB
~158K SLoC