cargo-lpatch

Crates.iocargo-lpatch
lib.rscargo-lpatch
version0.1.0
created_at2025-08-14 05:21:05.566284+00
updated_at2025-08-14 05:21:05.566284+00
descriptionA cargo plugin to locally patch dependencies by cloning them and setting up local patches
homepage
repositoryhttps://github.com/rcore-os/cargo-lpatch
max_upload_size
id1794452
size145,521
周睿 (ZR233)

documentation

README

cargo-lpatch

A cargo plugin to locally patch dependencies by cloning them and setting up local patches in .cargo/config.toml.

Installation

cargo install --path .

Or install from crates.io (once published):

cargo install cargo-lpatch

Usage

Basic Usage

Patch a crate from crates.io:

cargo lpatch --name serde

This will:

  1. Query crates.io for the serde crate's repository URL
  2. Clone the repository to crates/serde/
  3. Add a local patch configuration to .cargo/config.toml

Custom Clone Directory

Specify a custom directory for cloning:

cargo lpatch --name serde --dir my-dependencies

Direct Git URL

You can also provide a direct git URL instead of a crate name:

cargo lpatch --name https://github.com/serde-rs/serde.git

or

cargo lpatch --name git@github.com:serde-rs/serde.git

How It Works

  1. 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.

  2. Repository Cloning: The tool clones the repository to the specified directory (default: crates/).

  3. Configuration Update: The tool creates or updates .cargo/config.toml with a local patch configuration pointing to the cloned repository.

Generated Configuration

After running the tool, your .cargo/config.toml will contain something like:

[patch.crates-io]
serde = { path = "crates/serde" }

This tells Cargo to use the local version of the crate instead of downloading it from crates.io.

Examples

Patch multiple crates

cargo lpatch --name serde --dir deps
cargo lpatch --name tokio --dir deps
cargo lpatch --name clap --dir deps

Working with private repositories

cargo lpatch --name git@github.com:myorg/private-crate.git --dir vendor

Features

  • ✅ Query crates.io for repository URLs
  • ✅ Support for git URLs (https, ssh, git://)
  • ✅ Automatic .cargo/config.toml management
  • ✅ 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

at your option.

Commit count: 0

cargo fmt