cargo-lpatch
A cargo plugin to locally patch dependencies by cloning them and setting up local patches in .cargo/config.toml.
Installation
Or install from crates.io (once published):
Usage
Basic Usage
Patch a crate from crates.io:
This will:
- Query crates.io for the
serdecrate's repository URL - Clone the repository to
crates/serde/ - Add a local patch configuration to
.cargo/config.toml
Custom Clone Directory
Specify a custom directory for cloning:
Direct Git URL
You can also provide a direct git URL instead of a crate name:
or
How It Works
-
Crate Resolution: If you provide a crate name, the tool queries crates.io API to get the repository URL. If you provide a git URL, it uses that directly.
-
Repository Cloning: The tool clones the repository to the specified directory (default:
crates/). -
Configuration Update: The tool creates or updates
.cargo/config.tomlwith a local patch configuration pointing to the cloned repository.
Generated Configuration
After running the tool, your .cargo/config.toml will contain something like:
[]
= { = "crates/serde" }
This tells Cargo to use the local version of the crate instead of downloading it from crates.io.
Examples
Patch multiple crates
Working with private repositories
Features
- ✅ Query crates.io for repository URLs
- ✅ Support for git URLs (https, ssh, git://)
- ✅ Automatic
.cargo/config.tomlmanagement - ✅ Custom clone directories
- ✅ Progress indication for clone operations
- ✅ Update existing clones with
git pull - ✅ Smart URL cleaning and validation
Requirements
- Rust 1.70+
- Git installed and available in PATH
- Network access for crates.io queries and git operations
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.