File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,12 @@ fn parse_semver_flag(v: &str) -> CargoResult<VersionReq> {
286
286
. next ( )
287
287
. ok_or_else ( || format_err ! ( "no version provided for the `--version` flag" ) ) ?;
288
288
289
+ if let Some ( stripped) = v. strip_prefix ( "v" ) {
290
+ bail ! (
291
+ "the version provided, `{v}` is not a valid SemVer requirement\n \n \
292
+ help: try changing the version to `{stripped}`",
293
+ )
294
+ }
289
295
let is_req = "<>=^~" . contains ( first) || v. contains ( '*' ) ;
290
296
if is_req {
291
297
match v. parse :: < VersionReq > ( ) {
Original file line number Diff line number Diff line change @@ -2906,7 +2906,9 @@ fn prefixed_v_in_version() {
2906
2906
cargo_process ( "install foo@v0.0.1" )
2907
2907
. with_status ( 1 )
2908
2908
. with_stderr_data ( str![ [ r#"
2909
- [ERROR] invalid value 'foo@v0.0.1' for '[CRATE[@<VER>]]...': unexpected character 'v' while parsing major version number
2909
+ [ERROR] invalid value 'foo@v0.0.1' for '[CRATE[@<VER>]]...': the version provided, `v0.0.1` is not a valid SemVer requirement
2910
+
2911
+ [HELP] try changing the version to `0.0.1`
2910
2912
2911
2913
For more information, try '--help'.
2912
2914
You can’t perform that action at this time.
0 commit comments