We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
v
1 parent ac86dea commit 9ae361aCopy full SHA for 9ae361a
src/cargo/ops/cargo_add/crate_spec.rs
@@ -47,8 +47,16 @@ impl CrateSpec {
47
package_name?;
48
49
if let Some(version) = version {
50
- semver::VersionReq::parse(version)
51
- .with_context(|| format!("invalid version requirement `{version}`"))?;
+ semver::VersionReq::parse(version).with_context(|| {
+ if let Some(stripped) = version.strip_prefix("v") {
52
+ return format!(
53
+ "the version provided, `{version}` is not a \
54
+ valid SemVer requirement\n\n\
55
+ help: changing the package to `{name}@{stripped}`",
56
+ );
57
+ }
58
+ format!("invalid version requirement `{version}`")
59
+ })?;
60
}
61
62
let id = Self {
tests/testsuite/cargo_add/prefixed_v_in_version/stderr.term.svg
0 commit comments