#cargo #dependencies #crates #cli

bin+lib cargo-rhack

Temporarily edit your Cargo dependencies

5 releases

0.1.5 Mar 19, 2024
0.1.4 Mar 17, 2024
0.1.3 Mar 17, 2024
0.1.2 May 21, 2023
0.1.1 May 19, 2023

#1215 in Command line utilities

Download history 1/week @ 2024-02-16 6/week @ 2024-02-23 3/week @ 2024-03-01 6/week @ 2024-03-08 349/week @ 2024-03-15 40/week @ 2024-03-22 25/week @ 2024-03-29 7/week @ 2024-04-05

83 downloads per month

Custom license

32KB
369 lines

cargo-rhack

Version info

Description

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.

Usage

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.

Undoing

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.

Settings

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.

Installation

For MacOS, Linux, and Windows, prebuilt binaries are available through here.

Cargo

cargo install cargo-rhack

Binstall

cargo binstall cargo-rhack

Contributing

Found a bug? Open an issue!

Got an idea for an improvement? Don't keep it to yourself!

Code of Conduct

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.

Minimum Rust version policy

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.

Acknowledgements

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.

Original inspiration

This tool is highly inspired by gohack. It clearly stimulated an incentive to creation. A big "thank you!" goes out to them.

License

BSD-3-Clause license; see LICENSE.

Dependencies

~3–11MB
~115K SLoC