Skip to content

Bug: Cargo workspace = true dependencies stay at * instead of inheriting from [workspace.dependencies] #604

Closed

Description

@vibgrate-team

Context

parseCargoDepAttrs in src/core-open/scanners/rust-scanner.ts reads version = "…" from an inline table or [dependencies.<crate>] block, and the comment on that helper explicitly notes that workspace does not replace version. So a workspace-member Cargo.toml that writes

[dependencies]
serde = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread"] }

while the root declares

[workspace.dependencies]
serde = "1.0"
tokio = { version = "1.35", features = ["macros"] }

reports both crates with currentSpec / resolved version *. vg scan and vg sbom export then treat them as unpinned even though Cargo inherited a real version from the workspace table. Path- and git-only tables are a separate case; this issue is only about workspace = true inheritance.

What to do

  • When a dependency table sets workspace = true (and has no local version), look up the crate in the workspace root's [workspace.dependencies] and use that version (and any features/optional defaults the local table does not override).
  • Keep a local version = "…" winning over the workspace pin when both are present.
  • Leave path-/git-only tables without a version as they are today.
  • Add unit tests next to the other Cargo scanner tests (member + root fixture).

Acceptance

  • A member serde = { workspace = true } with root serde = "1.0" reports 1.0 (not *).
  • A member that also sets version = "2.0" keeps 2.0.
  • A path-only { path = "…" } table still does not invent a registry version.
  • Existing non-workspace Cargo fixtures stay green.

Activity

  1. added
    bug
    on Nov 5, 2026
  2. vibgrate-team commented on Nov 5, 2026

    @vibgrate-team
    ContributorAuthor

    Confirmed in parseCargoDepAttrs (src/core-open/scanners/rust-scanner.ts): the helper reads version / optional / features and the comment next to it already says workspace does not replace version. So serde = { workspace = true } lands as currentSpec: "*" even when the workspace root pins serde = "1.0" under [workspace.dependencies].

    A focused fix is: when the member table has workspace = true and no local version, walk up to the workspace root Cargo.toml, parse [workspace.dependencies].<crate>, and use that version (string or table). Keep a local version winning when both are set, and leave path-/git-only tables alone. A small workspace-member fixture plus a unit test on the inherited version is enough to lock it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions