Skip to content

Instantly share code, notes, and snippets.

@laurentsenta
Created August 10, 2022 14:02
Show Gist options
  • Save laurentsenta/e1ac5166d595245b8d278a4cab6caf96 to your computer and use it in GitHub Desktop.
Save laurentsenta/e1ac5166d595245b8d278a4cab6caf96 to your computer and use it in GitHub Desktop.
rust libp2p patch with features
[package]
edition = "2021"
name = "testplan"
version = "0.1.0"
[dependencies]
async-std = {version = "1.10", features = ["attributes", "tokio1"]}
env_logger = "0.9.0"
if-addrs = "0.7.0"
ipnetwork = {version = "0.19.0", default-features = false, features = ["serde"]}
log = "0.4"
rand = "0.8"
serde = {version = "1", features = ["derive"]}
serde_json = "1"
soketto = "0.7.1"
testground = {git = "https://github.com/testground/sdk-rust", branch = "master", version = "0.4.0"}
thiserror = "1"
tokio = { version = "1", default-features = false, features = ["sync", "rt-multi-thread", "macros", "net"] }
tokio-stream = { version = "0.1", default-features = false, features = [] }
tokio-util = { version = "0.7", default-features = false, features = ["compat"] }
futures = "0.3.1"
libp2pv0440 = {package = "libp2p", default_features = false, features = [ "websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std" ], version = "0.44.0", optional = true}
libp2pv0450 = {package = "libp2p", default_features = false, features = [ "websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std" ], version = "0.45.0", optional = true}
libp2pv0460 = {package = "libp2p", default_features = false, features = [ "websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std" ], version = "0.46.0", optional = true}
libp2pv0470 = {package = "libp2p", git = "https://github.com/libp2p/rust-libp2p", branch = "master", default_features = false, features = [ "websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std" ], version = "0.47.0", optional = true}
# attempt 1:
# [patch.crates-io]
# libp2pv0470 = { git = 'https://github.com/laurentsenta/rust-libp2p', branch = 'demo/pass' }
# result:
# › cargo build --features libp2pv0470 ☹
# Updating git repository `https://github.com/laurentsenta/rust-libp2p`
# error: failed to resolve patches for `https://github.com/rust-lang/crates.io-index`
# Caused by:
# patch for `libp2pv0470` in `https://github.com/rust-lang/crates.io-index` failed to resolve
# Caused by:
# The patch location `https://github.com/laurentsenta/rust-libp2p?branch=demo/pass` does not appear to contain any packages matching the name `libp2pv0470`.
# attempt 2:
# [patch.crates-io]
# libp2pv0470 = { package = 'libp2p', git = 'https://github.com/laurentsenta/rust-libp2p', branch = 'demo/pass' }
# result:
# cargo update && cargo build --features libp2pv0470
# › cargo build --features libp2pv0470 ☺
# warning: Patch `libp2p v0.47.0 (https://github.com/laurentsenta/rust-libp2p?branch=demo/pass#f888503a)` was not used in the crate graph.
# Check that the patched package version and available features are compatible
# with the dependency requirements. If the patch has a different version from
# what is locked in the Cargo.lock file, run `cargo update` to use the new
# version. This may also occur with an optional dependency that is not enabled.
# Finished dev [unoptimized + debuginfo] target(s) in 0.13s
# attempt 3:
[patch.crates-io]
libp2pv0470 = { package = 'libp2p', git = 'https://github.com/laurentsenta/rust-libp2p', branch = 'demo/pass', default_features = false, features = [ "websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std" ] }
# result
# › cargo build --features libp2pv0470 ☹
# Blocking waiting for file lock on package cache
# warning: patch for `libp2p` uses the features mechanism. default-features and features will not take effect because the patch dependency does not support this mechanism
# warning: Patch `libp2p v0.47.0 (https://github.com/laurentsenta/rust-libp2p?branch=demo/pass#f888503a)` was not used in the crate graph.
# Check that the patched package version and available features are compatible
# with the dependency requirements. If the patch has a different version from
# what is locked in the Cargo.lock file, run `cargo update` to use the new
# version. This may also occur with an optional dependency that is not enabled.
# Blocking waiting for file lock on build directory
# Finished dev [unoptimized + debuginfo] target(s) in 0.28s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment