Skip to content

Cargo package silently ignores patch entries when additional binaries are present #11181

Open
@leighmcculloch

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

  1. git clone https://github.com/stellar/rs-soroban-env

  2. cd rs-soroban-env

  3. git fetch origin pull/530/head:pr530

  4. git checkout pr530

  5. 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)
    
  6. git checkout HEAD~1 # go back one commit

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-patchArea: [patch] table overrideC-bugCategory: bugCommand-packageS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions