Skip to content
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

Confusing error for unrecognized dependency source #11781

Closed
ehuss opened this issue Feb 28, 2023 · 1 comment · Fixed by #11997
Closed

Confusing error for unrecognized dependency source #11781

ehuss opened this issue Feb 28, 2023 · 1 comment · Fixed by #11997
Assignees
Labels
A-manifest Area: Cargo.toml issues C-bug Category: bug Command-add

Comments

@ehuss
Copy link
Contributor

ehuss commented Feb 28, 2023

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]
@ehuss ehuss added C-bug Category: bug A-manifest Area: Cargo.toml issues Command-add labels Feb 28, 2023
@hi-rustin
Copy link
Member

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-manifest Area: Cargo.toml issues C-bug Category: bug Command-add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants