Skip to content

Misleading error message/diagnostic when package name is wrong #15561

@matthiasbeyer

Description

@matthiasbeyer

Problem

I just ran into an issue where I mistyped the name of a package in my workspace, and got an error message that is completely unrelated, which is confusing and led me into a complete different direction than what would have fixed the issue.

Steps

  1. Try to cargo build -p nonexisting-pkg --all-features a package that does not exist in the workspace
  2. Get error: cannot specify features for packages outside of workspace

Possible Solution(s)

I would expect an error message along the lines of

"Did not find package nonexisting-pkg in workspace"

Notes

No response

Version

cargo 1.85.0 (d73d2caf9 2024-12-31)                                                                                                                                                                                                            
release: 1.85.0                                                                                                                                                                                                                                
commit-hash: d73d2caf9e41a39daf2a8d6ce60ec80bf354d2a7                                                                                                                                                                                          
commit-date: 2024-12-31                                                                                                                                                                                                                        
host: x86_64-unknown-linux-gnu                                                                                                                                                                                                                 
libgit2: 1.8.1 (sys:0.19.0 vendored)                                                                                                                                                                                                           
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)                                                                                                                                                                         
ssl: OpenSSL 1.1.1w  11 Sep 2023                                                                                                                                                                                                               
os: NixOS 24.11.0 [64-bit]

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions