Description
This has now been rescoped to providing a good error message if a v
prefix is present, see #12331 (comment)
Problem
I keep doing something the following:
cargo add [email protected]
This causes the following error:
error: invalid version requirement `v0.5.0`
Caused by:
unexpected character 'v' while parsing major version number
I do this because I have a strong habit of prefixing my version numbers with v
where possible, as vX.Y.Z
tends to be a more unmistakable way to specify a version. And although it is not universal, it is also very common to prefix project release tags with v
— to the point that the canonical cargo
test for for a tag
dependency even uses a value like this: https://github.com/rust-lang/cargo/blob/5b377cece0e0dd0af686cf53ce4637d5d85c2a10/tests/testsuite/cargo_add/git_tag/mod.rs#L22C1-L22C1
(I know that doesn't have a semantic meaning in this case, but it illustrates how widespread it is to indicate a version using a prefix of v
.)
Further, other tools like npm
allow a prefix of v
(e.g. npm install [email protected]
), which is an inconsistency that causes a small stumbling block when working with multiple web technologies.
Proposed Solution
In order of preference:
- Accept an extra
v
before a semantic version number. - Recognize the extra
v
and provide a helpful error message that includes something like:If you want to install a specific version, please run: cargo add [email protected]
Notes
No response