Skip to content

cargo rustc panics on unknown bin #15493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jyn514 opened this issue May 6, 2025 · 2 comments · Fixed by #15497
Closed

cargo rustc panics on unknown bin #15493

jyn514 opened this issue May 6, 2025 · 2 comments · Fixed by #15497
Labels
C-bug Category: bug regression-from-stable-to-beta Regression in beta that previously worked in stable. S-triage Status: This issue is waiting on initial triage.

Comments

@jyn514
Copy link
Member

jyn514 commented May 6, 2025

Problem

thread 'main' panicked at src/tools/cargo/src/cargo/ops/cargo_compile/unit_generator.rs:302:26:
The number of packages must be at least 1
stack backtrace:
   3: core::option::expect_failed
             at /rustc/13e87909494f2f31bce51bc106e2b629420d1235/library/core/src/option.rs:2049:5
   4: <cargo::ops::cargo_compile::unit_generator::UnitGenerator>::list_rule_targets
   5: <cargo::ops::cargo_compile::unit_generator::UnitGenerator>::generate_root_units
   6: cargo::ops::cargo_compile::create_bcx
   7: cargo::ops::cargo_compile::compile_ws
   8: cargo::ops::cargo_compile::compile_with_exec
   9: cargo::ops::cargo_compile::compile
  10: cargo::commands::rustc::exec
  11: <cargo::cli::Exec>::exec
  12: cargo::main

Steps

  1. cargo new cargo-bug
  2. cd cargo-bug
  3. mkdir src/bin
  4. cargo rustc --bin main

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.88.0-nightly (7918c7eb5 2025-04-27)
release: 1.88.0-nightly
commit-hash: 7918c7eb59614c39f1c4e27e99d557720976bdd7
commit-date: 2025-04-27
host: x86_64-unknown-linux-gnu
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.12.1-DEV (sys:0.4.80+curl-8.12.1 vendored ssl:OpenSSL/3.4.1)
ssl: OpenSSL 3.4.1 11 Feb 2025
os: Pop!_OS 22.4.0 (jammy) [64-bit]
@jyn514 jyn514 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels May 6, 2025
@epage epage added regression-from-stable-to-nightly Regression in nightly that previously worked in stable. regression-from-stable-to-beta Regression in beta that previously worked in stable. and removed regression-from-stable-to-nightly Regression in nightly that previously worked in stable. labels May 6, 2025
@epage
Copy link
Contributor

epage commented May 6, 2025

Step (3) is not needed. Whats important is specifying an invalid --bin. Passing in --bin cargo-bug works.

Confirmed that

  • this is happens on nightly and beta but not stable
  • this only happens for rustc and not check or build

@epage epage changed the title cargo rustc crashes on empty src/bin folder cargo rustc panics on unknown bin May 6, 2025
@epage
Copy link
Contributor

epage commented May 6, 2025

I think I've narrowed this down to #15199, specifically fa7712d

... that would have gone faster looking at the backtrace

epage added a commit to epage/cargo that referenced this issue May 6, 2025
This takes the most surgical, direct route to addressing the problem.
Alternatively, we could look into why `cargo rustc` and `cargo check`
are different.

Fixes rust-lang#15493
epage added a commit to epage/cargo that referenced this issue May 6, 2025
This takes the most surgical, direct route to addressing the problem.
Alternatively, we could look into why `cargo rustc` and `cargo check`
are different.

Fixes rust-lang#15493
github-merge-queue bot pushed a commit that referenced this issue May 6, 2025
### What does this PR try to resolve?

Fixes #15493

### How should we test and review this PR?
This takes the most surgical, direct route to addressing the problem.
Alternatively, we could look into why `cargo rustc` and `cargo check`
are different.

### Additional information
weihanglo added a commit to weihanglo/cargo that referenced this issue May 6, 2025
### What does this PR try to resolve?

Fixes rust-lang#15493

### How should we test and review this PR?
This takes the most surgical, direct route to addressing the problem.
Alternatively, we could look into why `cargo rustc` and `cargo check`
are different.

### Additional information
weihanglo added a commit to weihanglo/cargo that referenced this issue May 10, 2025
### What does this PR try to resolve?

Fixes rust-lang#15493

### How should we test and review this PR?
This takes the most surgical, direct route to addressing the problem.
Alternatively, we could look into why `cargo rustc` and `cargo check`
are different.

### Additional information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug regression-from-stable-to-beta Regression in beta that previously worked in stable. S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants