self-replace

Crates.ioself-replace
lib.rsself-replace
version1.5.0
sourcesrc
created_at2023-05-14 14:12:27.182946
updated_at2024-09-01 10:30:38.713968
descriptionUtility crate that allows executables to replace or uninstall themselves
homepagehttps://github.com/mitsuhiko/self-replace
repositoryhttps://github.com/mitsuhiko/self-replace
max_upload_size
id864280
size58,352
Armin Ronacher (mitsuhiko)

documentation

README

Self-Replace: A Utility For Self Replacing Executables

Crates.io License rustc 1.63.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.

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.

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

License and Links

Commit count: 50

cargo fmt