From 5483bf9fdb35e2d2778ca4afba490e087cf59fef Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Fri, 5 Apr 2024 09:08:55 -0400 Subject: [PATCH] fix: properly fall back to netrc file (#592) We were early-exiting the loop. --- .../src/authentication_storage/backends/netrc.rs | 3 +++ .../rattler_networking/src/authentication_storage/storage.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/rattler_networking/src/authentication_storage/backends/netrc.rs b/crates/rattler_networking/src/authentication_storage/backends/netrc.rs index 95bad509c..0e0d4d003 100644 --- a/crates/rattler_networking/src/authentication_storage/backends/netrc.rs +++ b/crates/rattler_networking/src/authentication_storage/backends/netrc.rs @@ -39,6 +39,9 @@ impl NetRcStorage { Ok(val) => PathBuf::from(val), Err(_) => match dirs::home_dir() { Some(mut path) => { + #[cfg(windows)] + path.push("_netrc"); + #[cfg(not(windows))] path.push(".netrc"); path } diff --git a/crates/rattler_networking/src/authentication_storage/storage.rs b/crates/rattler_networking/src/authentication_storage/storage.rs index c4c8d0147..da61199c6 100644 --- a/crates/rattler_networking/src/authentication_storage/storage.rs +++ b/crates/rattler_networking/src/authentication_storage/storage.rs @@ -92,7 +92,7 @@ impl AuthenticationStorage { return Ok(Some(auth)); } Ok(None) => { - return Ok(None); + continue; } Err(e) => { tracing::warn!("Error retrieving credentials from backend: {}", e); @@ -100,7 +100,7 @@ impl AuthenticationStorage { } } - Err(anyhow!("All backends failed to retrieve credentials")) + Ok(None) } /// Retrieve the authentication information for the given URL