Skip to content

Confusing error for unrecognized dependency source #11781

Closed
@ehuss

Description

@ehuss

Problem

In some situations, cargo add (and possibly other commands?) will report a confusing error:

error: Unrecognized dependency source for `sqlx`

Even I took a bit to understand what this is saying, so I suspect it may be quite confusing for someone unfamiliar with cargo. Granted this is likely going to be a rare occurrence, though my particular situation was caused by #11630 which hopefully will get fixed.

Steps

Add the following to Cargo.toml:

[dependencies]
sqlx = { }

Then run cargo add sqlx --features postgres.

Possible Solution(s)

A partial fix will come in #11630 (my particular scenario was I misspelled version).

However, there may be other scenarios (like illustrated above) where this happens. I suggest adding more information and context to the error message. Perhaps it could explain what it was expecting (a version, git, or path field for example). It would also be nice to highlight the offending line (granted, it is likely a large endeavor to support error spans like rustc).

Notes

No response

Version

cargo 1.69.0-nightly (9d5b32f50 2023-02-22)
release: 1.69.0-nightly
commit-hash: 9d5b32f503fc099c4064298465add14d4bce11e6
commit-date: 2023-02-22
host: aarch64-apple-darwin
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0 (sys:0.4.59+curl-7.86.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 13.2.1 [64-bit]

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions