How to override a crate dependency?

⚓ Rust    📅 2026-03-14    👤 surdeus    👁️ 4      

surdeus

Hi I am trying to write and compile programs for the ps3. The program I wrote merely prints "Hello World" using the crate libc-print, which depends on the crate libc. I git cloned libc and made a trivial patch. But when I run cargo build libc-print still build libc from crates.io.

I never figured out how to make libc-print depend on my local fork of libc. Instead I had to clone libc-print and modify its libc dependency. I would like to know how to override a dependency of a crate from the Cargo.toml file rather than cloning every time a crate depends on libc.

My current solution:

[package]
name = "hello_core"
version = "0.1.0"
edition = "2024"

[dependencies]
libc-print = "0.1.23"
panic-halt = "1.0.0"

[patch.crates-io]
libc-print = { path = "../rust-libc-print"}

2 posts - 2 participants

Read full topic

🏷️ Rust_feed