Cargo package silently ignores patch entries when additional binaries are present #11181
Description
Problem
Running cargo package --no-verify
successfully packages crates in a workspace using the [patch.crates-io]
entries when validating the Cargo.toml file.
Running the same command fails in a workspace that has a crate with [[bin]]
in its Cargo.toml file, or an additional binary in a src/bin/...
file because the [patch]
entries get silently ignored.
Steps
-
git clone https://github.com/stellar/rs-soroban-env
-
cd rs-soroban-env
-
git fetch origin pull/530/head:pr530
-
git checkout pr530
-
cargo package --no-verify -p soroban-env-host
# will run without contacting crates.io.❯ cargo package --no-verify -p soroban-env-host Packaging soroban-env-host v0.0.6 (/Users/leighmcculloch/Code/rs-soroban-env/soroban-env-host)
-
git checkout HEAD~1
# go back one commit -
cargo package --no-verify -p soroban-env-host
# will fail after contacting crates.io and not finding a workspace crate dependency not published.❯ cargo package --no-verify -p soroban-env-host Packaging soroban-env-host v0.0.6 (/Users/leighmcculloch/Code/rs-soroban-env/soroban-env-host) Updating crates.io index error: failed to prepare local package for uploading Caused by: failed to select a version for the requirement `soroban-env-common = "^0.0.6"` candidate versions found which didn't match: 0.0.5, 0.0.4, 0.0.3, ... location searched: crates.io index required by package `soroban-env-host v0.0.6 (/Users/leighmcculloch/Code/rs-soroban-env/soroban-env-host)`
The only difference between the two commits is the removal of the additional binary.
Possible Solution(s)
This problem seems similar to:
Cargo package should use the patch entries when validating the toml regardless of whether there are [[bin]]
or additional binaries present.
Notes
This is an important capability because it allows a workspace to package its crates that have interdependencies without those crates being published, by allowing those crates to specify [patch.crates-io]
path entries.
Version
cargo 1.64.0 (387270bc7 2022-09-16)
release: 1.64.0
commit-hash: 387270bc7f446d17869c7f208207c73231d6a252
commit-date: 2022-09-16
host: aarch64-apple-darwin
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.79.1 (sys:0.4.55+curl-7.83.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 12.5.1 [64-bit]
Activity