https://github.com/mitsuhiko/self-replace
Utility library that helps to implement processes that replace themselves
https://github.com/mitsuhiko/self-replace
Last synced: about 2 months ago
JSON representation
Utility library that helps to implement processes that replace themselves
- Host: GitHub
- URL: https://github.com/mitsuhiko/self-replace
- Owner: mitsuhiko
- License: apache-2.0
- Created: 2023-05-14T13:14:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-23T21:20:05.000Z (10 months ago)
- Last Synced: 2025-05-12T02:06:52.760Z (about 2 months ago)
- Language: Rust
- Size: 67.4 KB
- Stars: 683
- Watchers: 5
- Forks: 26
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Self-Replace: A Utility For Self Replacing Executables
[](https://crates.io/crates/self-replace)
[](https://github.com/mitsuhiko/self-replace/blob/main/LICENSE)
[](https://img.shields.io/badge/rust-1.63%2B-orange.svg)
[](https://docs.rs/self-replace)`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](https://docs.rs/self-replace).
If you are looking for some higher level update logic, have a look at
[`self_update`](https://crates.io/crates/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`.
```rust
self_replace::self_delete()?;
```## Updating
To replace a binary for updating, use `self_replace`.
```rust
let new_binary = "/path/to/new/binary";
self_replace::self_replace(&new_binary)?;
std::fs::remove_file(&new_binary)?;
```## License and Links
* [Documentation](https://docs.rs/self-replace/)
* [Issue Tracker](https://github.com/mitsuhiko/self-replace/issues)
* [Examples](https://github.com/mitsuhiko/self-replace/tree/main/examples)
* License: [Apache-2.0](https://github.com/mitsuhiko/self-replace/blob/main/LICENSE)