Skip to content

Confusing error when publishing a package with a path dependency without a version requirement #15607

Open
@andrewdavidmackenzie

Description

@andrewdavidmackenzie

Problem

I used to use a cargo plugin to publish an entire workspace to crates.io, but now just tried the (unstable) built-in functionality with:

cargo +nightly publish -Z package-workspace --workspace

But I get this error reported:

error: all dependencies must have a version specified when publishing.
dependency `pigdef` 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.

The crate mentioned (pigdef) inherits the version from the workspace:

[package]
name = "pigdef"
description = "Core struct and const definitions for multiple crates in the pigg project"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
documentation.workspace = true
repository.workspace = true
homepage.workspace = true
readme.workspace = true
exclude.workspace = true
rust-version.workspace = true

My repo is here: https://github.com/andrewdavidmackenzie/pigg

Workspace members inheriting the package version from the workspace Cargo.toml seems fairly common practice, and so it would be great to have it working with cargo publish --workspace

Steps

  • Have a workspace repo with one or more members
  • Have the members inherit the package version from the workspace (rust-version.workspace = true)
  • Try to publish the workspace by running
cargo +nightly publish -Z package-workspace --workspace

Possible Solution(s)

No response

Notes

No response

Version

cargo version is 1.87.0
cargo nightly is...

cargo +nightly --version
cargo 1.89.0-nightly (68db37499 2025-05-22)

(so a week old, and seems to be the latest?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugCommand-packageCommand-publishS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions