Skip to content

Commit 40dae61

Browse files
committed
only suggest --git flag if scheme is http(s)
1 parent ecf05e4 commit 40dae61

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/bin/cargo/commands/install.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,13 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
123123
}
124124

125125
if let Ok(url) = crate_name.into_url() {
126-
return Err(anyhow!(
127-
"invalid package name: `{url}`
126+
if matches!(url.scheme(), "http" | "https") {
127+
return Err(anyhow!(
128+
"invalid package name: `{url}`
128129
Use `cargo install --git {url}` if you meant to install from a git repository."
129-
)
130-
.into());
130+
)
131+
.into());
132+
}
131133
}
132134
}
133135

0 commit comments

Comments
 (0)