Skip to content

cargo publish refuses path= dependencies, even though it probably oughtn't #14005

Closed as not planned
@nabijaczleweli

Description

@nabijaczleweli

Problem

cargo publish says

error: all dependencies must have a version specified when publishing.
dependency `iron` does not specify a version
Note: The published dependency will use the version from crates.io,
the `path` specification will be removed from the dependency declaration.

Steps

  1. have
    [dependencies.iron]
    path = "vendor/iron-0.6.1"
    features = ["hyper-native-tls"]
    in your Cargo.toml
  2. run cargo publish

Possible Solution(s)

Well. Don't? This has previously been #1565 and https://users.rust-lang.org/t/is-it-possible-to-publish-crates-with-path-specified/91497 however the forum bikesheds something unrelated while on the issue Crichton says

Such a feature is basically entirely incompatible with all of Cargo right now

and, maybe in 2017 it was. but in 2024 this is either (a) a staggering indictment of cargo as a whole or (b) an abject lie. This is trivially provable by running cargo build, or indeed cargo install --git on the same source.

These work and correctly resolve the dependency. Conversely, when publishing, cargo pretends this will not happen if it, uh... downloads the tarball itself and then runs cargo build there?
These are not fundamentally different, but this, once more (cf. #14001), contributes to anything-that-isn't-cargo-build being simply worse than downloading-the-tarball-yourself-and-running-cargo-build, by what appears to be an explicit decision.

Notes

Sure, validate all the paths point into the distribution tarball you're making, this seems reasonable, maybe even useful!

Version

cargo 1.78.0 (54d8815d0 2024-03-26)
release: 1.78.0
commit-hash: 54d8815d04fa3816edc207bbc4dd36bf18014dbc
commit-date: 2024-03-26
host: x86_64-pc-windows-gnu
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.14393 (Windows 10 Home) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-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