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> {
286286 . next ( )
287287 . ok_or_else ( || format_err ! ( "no version provided for the `--version` flag" ) ) ?;
288288
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+ }
289295 let is_req = "<>=^~" . contains ( first) || v. contains ( '*' ) ;
290296 if is_req {
291297 match v. parse :: < VersionReq > ( ) {
Original file line number Diff line number Diff line change @@ -2906,7 +2906,9 @@ fn prefixed_v_in_version() {
29062906 cargo_process ( "install foo@v0.0.1" )
29072907 . with_status ( 1 )
29082908 . 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`
29102912
29112913For more information, try '--help'.
29122914
You can’t perform that action at this time.
0 commit comments