Skip to content

Cannot publish when depending on a higher version of a dependency through path than registry #14022

Open
@epage

Description

@epage

Problem

clap_complete has a path dependency on clap

  • clap has a registry dependency on divan
    • divan has a registry dependency on clap

My lockfile had clap@4.4.17 (registry) in it but clap_complete depended on clap = "4.5.6".

So when cargo package verifies the .crate file, it is locked to the version of clap from my Cargo.lock which can't satisfy the version requirement.

    Updating crates.io index
error: failed to prepare local package for uploading

Caused by:
  failed to select a version for `clap`.
      ... required by package `clap_complete v4.5.3 (/home/epage/src/personal/clap/clap_complete)`
  versions that meet the requirements `^4.0.0` (locked to 4.4.17) are: 4.4.17

  all possible versions conflict with previously selected packages.

    previously selected package `clap v4.5.6`
      ... which satisfies dependency `clap = "^4.5.6"` of package `clap_complete v4.5.3 (/home/epage/src/personal/clap
/clap_complete)`

  failed to select a version for `clap` which could resolve this conflict

Steps

Checkout clap-rs/clap@3572ab8

Run cargo package -p clap_complete --dry-run and see it fail

Run cargo update clap@4.4.17

Run cargo package -p clap_complete --dry-run and see it pass

Possible Solution(s)

Unsure if there is a good solution to prevent the error but just improving the error message would be a big help.

However, I can see improving the error message being difficult because it might require context about cargo package that the resolver doesn't have.

Notes

No response

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dependency-resolutionArea: dependency resolution and the resolverA-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugCommand-packageCommand-publishS-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