Skip to content

fix: detect circular publish dependency cycle in workspace publish#16722

Merged
epage merged 2 commits intorust-lang:masterfrom
raushan728:fix-issue-16682
Mar 17, 2026
Merged

fix: detect circular publish dependency cycle in workspace publish#16722
epage merged 2 commits intorust-lang:masterfrom
raushan728:fix-issue-16682

Conversation

@raushan728
Copy link
Copy Markdown
Contributor

Fixes #16682

What does this PR try to resolve?

Detects circular publish dependency early and bails
with a clear error instead of silently timing out
with a blank warning message.

How to test and review this PR?

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 8, 2026

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@rustbot rustbot added A-interacts-with-crates.io Area: interaction with registries Command-publish S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 8, 2026
@raushan728 raushan728 requested a review from epage March 10, 2026 10:14
@raushan728
Copy link
Copy Markdown
Contributor Author

I moved the cycle detection before the publish loop
by adding a has_cycles() method to PublishPlan that
checks if all packages have unmet dependencies
(weight > 0) but none are ready.

This way the error is thrown before any crate gets
published, avoiding a partially-published state.

All 133 publish tests pass with this approach.

@raushan728
Copy link
Copy Markdown
Contributor Author

  • Added cycle_members() to report only packages
    actually forming the cycle, not all blocked ones
  • Replaced break with crate::util::internal()
    for unexpected empty ready state
  • Added a second test verifying non-cycle package
    is not mentioned in the error

@raushan728 raushan728 requested a review from epage March 11, 2026 06:40
@raushan728 raushan728 requested a review from epage March 12, 2026 13:16
@raushan728 raushan728 force-pushed the fix-issue-16682 branch 2 times, most recently from d93d523 to a063304 Compare March 14, 2026 06:39
@raushan728 raushan728 closed this Mar 14, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 14, 2026
@raushan728 raushan728 reopened this Mar 14, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 14, 2026
@raushan728
Copy link
Copy Markdown
Contributor Author

@epage
cycle_members() now uses topological sort
with the original graph (dependent -> dependency).

  • c is correctly excluded from cycle members
  • Error is reported before any uploads occur

Copy link
Copy Markdown
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epage epage added this pull request to the merge queue Mar 17, 2026
Merged via the queue into rust-lang:master with commit fb7c0f1 Mar 17, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 17, 2026
@raushan728 raushan728 deleted the fix-issue-16682 branch March 17, 2026 15:54
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Mar 20, 2026
Update cargo submodule

13 commits in cbb9bb8bd0fb272b1be0d63a010701ecb3d1d6d3..d81735547e5f2844322f36380ab66f549cda11b9
2026-03-13 14:34:16 +0000 to 2026-03-20 13:20:51 +0000
- cargo clean: Validate that target_dir is not a file  (rust-lang/cargo#16765)
- fix: fetching non-standard git refspecs on non-github repos (rust-lang/cargo#16768)
- Update tar to 0.4.45 (rust-lang/cargo#16771)
- chore: Remove edition_lint_opts from Lint (rust-lang/cargo#16762)
- refactor: split out several smaller changes to prepare for async http (rust-lang/cargo#16763)
- fix(compile): Make build.warnings ignore non-local deps (rust-lang/cargo#16760)
- fix: detect circular publish dependency cycle in workspace publish (rust-lang/cargo#16722)
- refactor(shell): Pull out term integration into `anstyle-progress` (rust-lang/cargo#16757)
- test: reproduce rustfix panic on overlapping suggestions (rust-lang/cargo#16705)
- fix: Avoid panic for package specs with an empty fragment (rust-lang/cargo#16754)
- refactor(registry): avoid dynamic dispatch for Registry trait (rust-lang/cargo#16752)
- refactor(shell): Pull out hyperlink logic into anstyle-hyperlink (rust-lang/cargo#16749)
- refactor(install): Remove dead code (rust-lang/cargo#16718)

r? ghost
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Mar 21, 2026
Update cargo submodule

14 commits in cbb9bb8bd0fb272b1be0d63a010701ecb3d1d6d3..e84cb639edfea2c42efd563b72a9be0cc5de6523
2026-03-13 14:34:16 +0000 to 2026-03-21 01:27:07 +0000
- Fix symlink_and_directory when running in a long target dir name (rust-lang/cargo#16775)
- cargo clean: Validate that target_dir is not a file  (rust-lang/cargo#16765)
- fix: fetching non-standard git refspecs on non-github repos (rust-lang/cargo#16768)
- Update tar to 0.4.45 (rust-lang/cargo#16771)
- chore: Remove edition_lint_opts from Lint (rust-lang/cargo#16762)
- refactor: split out several smaller changes to prepare for async http (rust-lang/cargo#16763)
- fix(compile): Make build.warnings ignore non-local deps (rust-lang/cargo#16760)
- fix: detect circular publish dependency cycle in workspace publish (rust-lang/cargo#16722)
- refactor(shell): Pull out term integration into `anstyle-progress` (rust-lang/cargo#16757)
- test: reproduce rustfix panic on overlapping suggestions (rust-lang/cargo#16705)
- fix: Avoid panic for package specs with an empty fragment (rust-lang/cargo#16754)
- refactor(registry): avoid dynamic dispatch for Registry trait (rust-lang/cargo#16752)
- refactor(shell): Pull out hyperlink logic into anstyle-hyperlink (rust-lang/cargo#16749)
- refactor(install): Remove dead code (rust-lang/cargo#16718)
@rustbot rustbot added this to the 1.96.0 milestone Mar 21, 2026
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Mar 27, 2026
Update cargo submodule

14 commits in cbb9bb8bd0fb272b1be0d63a010701ecb3d1d6d3..e84cb639edfea2c42efd563b72a9be0cc5de6523
2026-03-13 14:34:16 +0000 to 2026-03-21 01:27:07 +0000
- Fix symlink_and_directory when running in a long target dir name (rust-lang/cargo#16775)
- cargo clean: Validate that target_dir is not a file  (rust-lang/cargo#16765)
- fix: fetching non-standard git refspecs on non-github repos (rust-lang/cargo#16768)
- Update tar to 0.4.45 (rust-lang/cargo#16771)
- chore: Remove edition_lint_opts from Lint (rust-lang/cargo#16762)
- refactor: split out several smaller changes to prepare for async http (rust-lang/cargo#16763)
- fix(compile): Make build.warnings ignore non-local deps (rust-lang/cargo#16760)
- fix: detect circular publish dependency cycle in workspace publish (rust-lang/cargo#16722)
- refactor(shell): Pull out term integration into `anstyle-progress` (rust-lang/cargo#16757)
- test: reproduce rustfix panic on overlapping suggestions (rust-lang/cargo#16705)
- fix: Avoid panic for package specs with an empty fragment (rust-lang/cargo#16754)
- refactor(registry): avoid dynamic dispatch for Registry trait (rust-lang/cargo#16752)
- refactor(shell): Pull out hyperlink logic into anstyle-hyperlink (rust-lang/cargo#16749)
- refactor(install): Remove dead code (rust-lang/cargo#16718)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-interacts-with-crates.io Area: interaction with registries Command-publish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"timed out waiting for to be available in registry crates-io"

3 participants