-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
C-bugCategory: bugCategory: bugCommand-addS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Description
Problem
When accidentally specifying a workspace-level dependency as cratename.workspace = true
and then trying to add it to a workspace-crate via cargo add cratename
, instead of producing a proper error message cargo add panics
Steps
- Create a workspace
- In workspace's root, add a
[workspace.dependencies]
block - Add
apply.workspace = true
to that block (or any other crate) - Create a workspace crate (for example,
cargo new testing
) - Change directory to the crate's root (
cd ./testing
) - Use
cargo add apply
(or a different previously specified crate) from crate's root
On step 6, cargo add
panics with the following
thread 'main' panicked at src/tools/cargo/src/cargo/ops/cargo_add/mod.rs:519:21:
internal error: entered unreachable code: This should have been caught when parsing a workspace root
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Possible Solution(s)
Adding a proper error message could be nice, as this is a type of error one can make while copypasting Cargo.toml when moving stuff around/creating a workspace
Notes
No response
Version
cargo 1.90.0 (840b83a10 2025-07-30)
release: 1.90.0
commit-hash: 840b83a10fb0e039a83f4d70ad032892c287570a
commit-date: 2025-07-30
host: x86_64-unknown-linux-gnu
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.14.1-DEV (sys:0.4.82+curl-8.14.1 vendored ssl:OpenSSL/3.5.0)
ssl: OpenSSL 3.5.0 8 Apr 2025
os: Arch Linux Rolling Release [64-bit]
Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bugCommand-addS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review