Problem
If you mistype the package name to the -p flag and also specify the --features flag, then cargo emits a rather confusing error message:
error: cannot specify features for packages outside of workspace
If you're lucky, and the typo is close to an existing package name, then cargo may say something like:
help: a workspace member with a similar name exists: `foo-bar`
but even then the primary error message seems wrong, and the help text is incongruent with the error being about features.
Steps
- In some workspace, such as cargo's own workspace, run a command like
cargo test -p foo_bar -F asdf
The actual features specified doesn't matter.
Possible Solution(s)
I would expect the error message to be the same as when --features is not specified:
error: package ID specification `foo_bar` did not match any packages
help: a workspace member with a similar name exists: `foo-bar`
Notes
No response
Version
cargo 1.97.0-nightly (4f9b52075 2026-05-01)
release: 1.97.0-nightly
commit-hash: 4f9b52075316e9ced380c8fa492858048d5758b6
commit-date: 2026-05-01
host: x86_64-unknown-linux-gnu
libgit2: 1.9.2 (sys:0.20.4 vendored)
libcurl: 8.20.0-DEV (sys:0.4.88+curl-8.20.0 vendored ssl:OpenSSL/3.6.2)
ssl: OpenSSL 3.6.2 7 Apr 2026
os: Ubuntu 24.4.0 (noble) [64-bit]
Problem
If you mistype the package name to the
-pflag and also specify the--featuresflag, then cargo emits a rather confusing error message:If you're lucky, and the typo is close to an existing package name, then cargo may say something like:
but even then the primary error message seems wrong, and the help text is incongruent with the error being about features.
Steps
cargo test -p foo_bar -F asdfThe actual features specified doesn't matter.
Possible Solution(s)
I would expect the error message to be the same as when
--featuresis not specified:Notes
No response
Version