nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.22k stars 42 forks source link

"malformed URL '' " Error on Update #109

Closed tuxiqae closed 5 years ago

tuxiqae commented 5 years ago

Hi guys, When I try to run the command cargo install-update --all or cargo install-update <package name> for some reason I receive the following error -

Updating registry 'https://github.com/rust-lang/crates.io-index' Failed to update index repository: malformed URL ''.

I tried both force updating cargo-update and removing and installing it from scratch - both didn't solve the issue. I would like to add that it previously ran perfectly but stopped a couple of weeks ago.

I'm using Arch Linux 64-bit.

Thanks

nabijaczleweli commented 5 years ago

That's… peculiar?

The only error in that format is here and a couple lines down, and the error can only have originated from this call chain, so either repo_url would have to be empty despite being printed above, or http_proxy is Some("").

You might have any of: $http_proxy, $HTTP_PROXY, $https_proxy, $HTTPS_PROXY set but empty, or have one of your configs messed up. If unsetting one or all of the above still doesn't work, could you try the following patch on top of current master for diagnosis?

diff --git a/src/ops/mod.rs b/src/ops/mod.rs
index aa11e32d4..ce4596128 100644
--- a/src/ops/mod.rs
+++ b/src/ops/mod.rs
@@ -905,17 +905,21 @@ pub fn find_proxy(crates_file: &Path) -> Option<String> {
             .and_then(|t| t.as_table())
             .and_then(|t| t.get("proxy"))
             .and_then(|t| t.as_str()) {
+            println!("cargo proxy: {:?}", proxy);
             return Some(proxy.to_string());
         }
     }

     if let Ok(cfg) = GitConfig::open_default() {
         if let Ok(s) = cfg.get_str("http.proxy") {
+            println!("git proxy: {:?}", s);
             return Some(s.to_string());
         }
     }

-    ["http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY"].iter().flat_map(env::var).next()
+    let ret = ["http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY"].iter().flat_map(env::var).next();
+    println!("env proxy: {:?}", ret);
+    ret
 }

 /// Find the bare git repository in the specified directory for the specified crate

Allowing empty environment proxies does seem like a bug, though, and if that turns out to be the culprit, I'll definitely correct it.

tuxiqae commented 5 years ago

Well, I tried unsetting all 4 variables but it didn't help. After implementing the patches I ran the program and received the following output:

[user@localhost:~/Clones/cargo-update/target/release]$> ./cargo-install-update install-update racer env proxy: Some("") Updating registry 'https://github.com/rust-lang/crates.io-index' Failed to update index repository: malformed URL ''.

tuxiqae commented 5 years ago

I might be free in the next 20 minutes, text me if you got any idea :)

nabijaczleweli commented 5 years ago

Right, the commit referenced above should ignore all empty proxies, so if you could try with that?

tuxiqae commented 5 years ago

Seems like it finally worked :) Good job mate!

nabijaczleweli commented 5 years ago

Released in v1.8.4.