Crates.io | cargo-rhack |
lib.rs | cargo-rhack |
version | 0.1.5 |
source | src |
created_at | 2023-05-19 23:59:30.299474 |
updated_at | 2024-03-19 06:19:39.13989 |
description | Temporarily edit your Cargo dependencies |
homepage | https://github.com/simonsan/cargo-rhack |
repository | https://github.com/simonsan/cargo-rhack |
max_upload_size | |
id | 869150 |
size | 100,325 |
You want to quickly put a sneaky macro kind of like dbg!
into external crates
to find out how some internal data structure works? If so cargo-rhack
is for
you!
cargo-rhack
makes it easier to edit external crates code that your project
depends on.
Let's say you want to modify the reqwest
crate.
[dependencies]
reqwest = "0.11"
Run the following:
cargo rhack edit reqwest
This will make a copy of the crate into $HOME/.rhack/reqwest-0.11.1
and add
its path to the
[patch] section
in your Cargo.toml whose path is automatically detected:
[patch.crates-io]
reqwest = { path = "/home/you/.rhack/reqwest-0.11.1" }
Now your package uses the locally checked out copy instead of one from crates.io. You can now open the files (typically by leveraging the "Jump to Definition" feature) and then feel free to modify the source code.
Simply run the undo
command then you can undo all of the changes to your
Cargo.toml:
cargo rhack undo
Keep in mind that this command doesn't remove any copy of crates.
It uses $HOME/.rhack
as the destination to copy the source code of the
external crates by default. You can change it by setting and exposing the
$RHACK_DIR
environment variable.
For MacOS, Linux, and Windows, prebuilt binaries are available through here.
cargo install cargo-rhack
cargo binstall cargo-rhack
Found a bug? Open an issue!
Got an idea for an improvement? Don't keep it to yourself!
Please review and abide by the general Rust Community Code of Conduct when contributing to this project. In the future, we might create our own Code of Conduct and supplement it at this location.
This crate's minimum supported rustc
version is 1.74.1
.
The current policy is that the minimum Rust version required to use this crate
can be increased in minor version updates. For example, if crate 1.0
requires
Rust 1.20.0, then crate 1.0.z
for all values of z
will also require Rust
1.20.0 or newer. However, crate 1.y
for y > 0
may require a newer minimum
version of Rust.
In general, this crate will be conservative with respect to the minimum supported version of Rust.
The original author of this tool is nakabonne, I revived it and fixed some things. I'm grateful for the original author's efforts and contributions to the Rust community. I hope this tool will be useful for many people in the Rust community going forward.
This tool is highly inspired by gohack. It clearly stimulated an incentive to creation. A big "thank you!" goes out to them.
BSD-3-Clause license; see LICENSE.