-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Package ID specification urls must contain a host #9188
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
Oops. Seems some url like |
Thanks for taking a look at this. Unfortunately, specs are kind of a mess right now (see #7725). The It might be nice to detect the scenario someone gives a path and provide a better error message (like maybe suggest using |
Updated. However it still unwraps a |
So, I was thinking it could flip the if spec.contains("://") {
if let Ok(url) = spec.into_url() {
return PackageIdSpec::from_url(url);
}
} else if spec.contains('/') || spec.contains('\\') {
let abs = std::env::current_dir().unwrap_or_default().join(spec);
if abs.exists() {
let maybe_url = Url::from_file_path(abs)
.map_or_else(|_| "a file:// URL".to_string(), |url| url.to_string());
bail!(
"package ID specification `{}` looks like a file path, \
maybe try {}",
spec,
maybe_url
);
}
} And completely remove the The error I wrote above still isn't great. Ideally it would actually tell you what the correct value is. The tests need to be updated, and ideally there would be a UI test (maybe just add another case to Also, the documentation should be updated ( |
@ehuss |
Thanks! Sorry, I think I was mistaken on the docs, but your change seems fine. I was thinking of the pkgid-spec.md file. I'll follow up with an update to that. @bors r+ |
@ehuss: 🔑 Insufficient privileges: Not in reviewers |
@bors r+ |
📌 Commit c5d2304 has been approved by |
☀️ Test successful - checks-actions |
Posted #9249 with an update to the spec docs that I was thinking of. |
Update cargo 7 commits in 970bc67c3775781b9708c8a36893576b9459c64a..32da9eaa5de5be241cf8096ca6b749a157194f77 2021-03-07 18:09:40 +0000 to 2021-03-13 01:18:40 +0000 - Fix logic for determining prefer-dynamic for a dylib. (rust-lang/cargo#9252) - Fix issue with filtering exclusive target dependencies. (rust-lang/cargo#9255) - Update pkgid-spec docs. (rust-lang/cargo#9249) - Wordsmith the edition documentation a bit more (rust-lang/cargo#9233) - Package ID specification urls must contain a host (rust-lang/cargo#9188) - Add documentation for JSON message_path. (rust-lang/cargo#9247) - Fix filter_platform to run on targets other than x86. (rust-lang/cargo#9246)
Update cargo 7 commits in 970bc67c3775781b9708c8a36893576b9459c64a..32da9eaa5de5be241cf8096ca6b749a157194f77 2021-03-07 18:09:40 +0000 to 2021-03-13 01:18:40 +0000 - Fix logic for determining prefer-dynamic for a dylib. (rust-lang/cargo#9252) - Fix issue with filtering exclusive target dependencies. (rust-lang/cargo#9255) - Update pkgid-spec docs. (rust-lang/cargo#9249) - Wordsmith the edition documentation a bit more (rust-lang/cargo#9233) - Package ID specification urls must contain a host (rust-lang/cargo#9188) - Add documentation for JSON message_path. (rust-lang/cargo#9247) - Fix filter_platform to run on targets other than x86. (rust-lang/cargo#9246)
Resolves #9041
Not sure which commit breaks this. Cargo shipped with rust 1.46 didn't unwrap on a
None
but 1.47 did. Even checkouted to 149022b (cargo of rust 1.46), it still unwrap unexpectedly.So I ended up following the Specification grammer to make sure there is a
host
in the pkgid urls.See console output
cargo of rust 1.46
cargo of rust 1.47
cargo on commit 149022b