Skip to content

Support splicing manifests from multiple Cargo workspaces#3934

Open
malt3 wants to merge 3 commits intobazelbuild:mainfrom
malt3:malt3-cargo-multi-workspace
Open

Support splicing manifests from multiple Cargo workspaces#3934
malt3 wants to merge 3 commits intobazelbuild:mainfrom
malt3:malt3-cargo-multi-workspace

Conversation

@malt3
Copy link
Copy Markdown

@malt3 malt3 commented Mar 27, 2026

When manifests come from different Cargo workspaces (e.g. a primary
workspace depending on crates in a separate external workspace),
splicing previously failed with "manifests are not allowed to come from
different workspaces". Additionally, external relative paths aren't resolved.

This change:

  • Adds main_manifest to SplicingManifest so the splicer can
    disambiguate which workspace root is primary when multiple are found.
  • Nests the spliced workspace at its repo-relative depth inside the temp
    dir so that ../ path deps resolve within the temp dir instead of
    escaping into unwritable system directories.
  • Collects path deps from [workspace.dependencies] in addition to
    per-package deps.
  • Symlinks entire foreign workspace root directories (not just crate
    dirs) so Cargo can walk up and resolve dep.workspace = true
    inherited dependencies.
  • Wires main_manifest through extensions.bzl and crates_vendor.bzl.
  • Calls symlink_external_path_deps from the cargo_tree_resolver so
    cargo tree also sees external path deps.

This fixes #3089,
along with adding support for multiple workspaces in the splicer.

Co-Authored-By: Steve Barrau 98589981+stevebarrau@users.noreply.github.com

…d#3089)

This test reproduces the bug where crate_universe fails when a Cargo
workspace member has a path dependency pointing outside the Cargo
workspace root (but still inside the Bazel workspace).

The test is expected to fail until the bug is fixed.
@malt3 malt3 force-pushed the malt3-cargo-multi-workspace branch 3 times, most recently from bc7ba6d to 356dd1e Compare March 27, 2026 12:08
malt3 and others added 2 commits March 27, 2026 12:18
When manifests come from different Cargo workspaces (e.g. a primary
workspace depending on crates in a separate external workspace),
splicing previously failed with "manifests are not allowed to come from
different workspaces".

This change:
- Adds `main_manifest` to SplicingManifest so the splicer can
  disambiguate which workspace root is primary when multiple are found.
- Nests the spliced workspace at its repo-relative depth inside the temp
  dir so that `../` path deps resolve within the temp dir instead of
  escaping into unwritable system directories.
- Collects path deps from `[workspace.dependencies]` in addition to
  per-package deps.
- Symlinks entire foreign workspace root directories (not just crate
  dirs) so Cargo can walk up and resolve `dep.workspace = true`
  inherited dependencies.
- Wires `main_manifest` through extensions.bzl and crates_vendor.bzl.
- Calls symlink_external_path_deps from the cargo_tree_resolver so
  `cargo tree` also sees external path deps.

This fixes bazelbuild#3089,
along with adding support for multiple workspaces in the splicer.

Co-Authored-By: Steve Barrau <98589981+stevebarrau@users.noreply.github.com>
@malt3 malt3 force-pushed the malt3-cargo-multi-workspace branch from 356dd1e to 275962d Compare March 27, 2026 12:20
@malt3 malt3 marked this pull request as ready for review March 27, 2026 13:03
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.

External relative path dependencies not working

2 participants