Skip to content

Publishing a crate with unpublished dependencies #6738

Closed

Description

I'd like to publish a crate that depends on various crates from tower-rs, which are not yet themselves published. I'm not sure how to do this.


If I specify the dependencies in Cargo.toml as sourced from git:

tower-grpc = { git = "https://github.com/tower-rs/tower-grpc", rev = "94a7b51" }
tower-grpc-build = { git = "https://github.com/tower-rs/tower-grpc", rev = "94a7b51" }
tower-add-origin = { git = "https://github.com/tower-rs/tower-http", rev = "6d7a9fd" }
tower-h2 = { git = "https://github.com/tower-rs/tower-h2", rev = "71effe1" }
tower-service = "0.2"
tower-util = { git = "https://github.com/tower-rs/tower", rev = "50fc5e8" }

I can get as far as packaging, but not publish:

$ cargo publish
    Updating crates.io index
error: crates cannot be published with dependencies sourced from a repository
either publish `tower-grpc` as its own crate and specify a version as a dependency or pull it into this repository and specify it with a path and version
(crate `tower-grpc` has repository path `https://github.com/tower-rs/tower-grpc?rev=94a7b51`)

If I pull in the dependencies as submodules and use paths in Cargo.toml:

tower-grpc = { path = "tower/tower-grpc", version = "0.1.0" }
tower-grpc-build = { path = "tower/tower-grpc/tower-grpc-build", version = "0.1.0" }
tower-add-origin = { path = "tower/tower-http/tower-add-origin", version = "0.1.0" }
tower-h2 = { path = "tower/tower-h2", version = "0.1.0" }
tower-service = "0.2"
tower-util = { path = "tower/tower/tower-util", version = "0.1.0" }

I can't package because it's trying to pull the crates from crates.io:

$ cargo package
...
error: failed to verify package tarball

Caused by:
  failed to select a version for the requirement `tower-grpc = "^0.1.0"`
  candidate versions found which didn't match: 0.0.0
  location searched: crates.io index
required by package `pachyderm v0.1.0 (/Users/yusuf/work/rust-pachyderm/target/package/pachyderm-0.1.0)`

If I use patch:

tower-grpc = "0.1.0"
tower-grpc-build = "0.1.0"
tower-add-origin = "0.1.0"
tower-h2 = "0.1.0"
tower-service = "0.2"
tower-util = "0.1.0"

[patch.crates-io]
tower-grpc = { path = "tower/tower-grpc" }
tower-grpc-build = { path = "tower/tower-grpc/tower-grpc-build" }
tower-add-origin = { path = "tower/tower-http/tower-add-origin" }
tower-h2 = { path = "tower/tower-h2" }
tower-util = { path = "tower/tower/tower-util" }

I get the same verification error when packaging.

Observed on stable v1.33.0.

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-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions