Skip to content

Easy to mess up wrapper/proc-macro dependency relationship #16229

@ultimaweapon

Description

@ultimaweapon

Problem

I accidentally publish a crate that depend on an old version of macro crate due to everything working fine from a local repository. My main crate look like this:

[package]
name = "tsuki"
version = "0.3.1"
edition = "2024"

[dependencies]
tsuki-macros = { version = "0.1.0", path = "macros" }

This crate re-export macros from tsuki-macros. The problem is I added a new macro to tsuki-macros and bump its version then re-export it on tsuki but forgot to update the dependency version. This caused the following error for people who already have tsuki-macros in their cache while everything are working fine from the local repository:

error[E0432]: unresolved import `tsuki_macros::class`
   --> /home/ultimaweapon/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tsuki-0.3.1/src/lib.rs:310:9
    |
310 | pub use tsuki_macros::class;
    |         ^^^^^^^^^^^^^^^^^^^ no `class` in the root
    |

Proposed Solution

I propose that version should be optional when path is specified for a dependency during publish. In this case the version should be fetched from the dependency.

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.A-manifestArea: Cargo.toml issuesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-publishS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions