Skip to content

Conversation

@doug-helios
Copy link

@doug-helios doug-helios commented Oct 8, 2025

When building a source distribution for a crate that is excluded from
its parent workspace (or has its own workspace) but depends on sibling
crates in the parent workspace, maturin would panic with StripPrefixError.

This occurred because the code assumed that a path dependency's workspace
manifest would always be inside the sdist root, using .unwrap() on the
result of strip_prefix().

The fix replaces .unwrap() with if let Ok() to gracefully handle
workspace manifests outside the sdist boundary. When this occurs, we
skip including the external workspace manifest and log a debug message.

This is safe because:

  • The path dependency's own Cargo.toml is still included in the sdist
  • External workspace manifests aren't needed for building from sdist
  • Cargo resolves dependencies from the included crate's manifest

Adds test case lib_with_parent_workspace_path_dep_sdist that reproduces
the scenario with a parent workspace excluding a crate that depends on
sibling workspace members.

Fixes scenarios like:

repo/
├── Cargo.toml              # Workspace with exclude = ["pysof"]
└── crates/
    ├── shared/             # Part of parent workspace
    └── pysof/              # Excluded, has own workspace
        └── [depends on ../shared via path]

Resolves: HeliosSoftware/hfs#15 (real-world reproduction)
Small repo to reproduce issue: https://github.com/doug-helios/maturin-sdist-bug-repro

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant