From 144ada465c720edd141f74bcbae60b8c33fd39e8 Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Mon, 10 Jul 2023 17:33:06 +0200 Subject: [PATCH] fix: allow not finding arch platforms in channel (#164) --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 2 +- src/render/solver.rs | 22 ++++++++++++++++++---- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2d7329a8..2edc361e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3313,7 +3313,7 @@ dependencies = [ [[package]] name = "rattler" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "anyhow", "apple-codesign", @@ -3404,7 +3404,7 @@ dependencies = [ [[package]] name = "rattler_conda_types" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "chrono", "fxhash", @@ -3432,7 +3432,7 @@ dependencies = [ [[package]] name = "rattler_digest" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "blake2", "digest 0.10.7", @@ -3447,7 +3447,7 @@ dependencies = [ [[package]] name = "rattler_libsolv_c" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "anyhow", "cc", @@ -3460,7 +3460,7 @@ dependencies = [ [[package]] name = "rattler_macros" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "quote", "syn 2.0.18", @@ -3469,7 +3469,7 @@ dependencies = [ [[package]] name = "rattler_networking" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "anyhow", "dirs 5.0.1", @@ -3486,7 +3486,7 @@ dependencies = [ [[package]] name = "rattler_package_streaming" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "bzip2", "chrono", @@ -3509,7 +3509,7 @@ dependencies = [ [[package]] name = "rattler_repodata_gateway" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "anyhow", "async-compression", @@ -3547,7 +3547,7 @@ dependencies = [ [[package]] name = "rattler_shell" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "enum_dispatch", "indexmap 1.9.3", @@ -3563,7 +3563,7 @@ dependencies = [ [[package]] name = "rattler_solve" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "anyhow", "hex", @@ -3581,7 +3581,7 @@ dependencies = [ [[package]] name = "rattler_virtual_packages" version = "0.5.0" -source = "git+https://github.com/mamba-org/rattler?branch=main#e0d52607aa14b501b49f2b611b8d3a7e4b1e235e" +source = "git+https://github.com/mamba-org/rattler?branch=main#8c7b49bb5b509db6d0383cd24d9e4812b5a5e493" dependencies = [ "cfg-if", "libloading", diff --git a/Cargo.toml b/Cargo.toml index 7a098acc..3262724e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ rattler_networking = { git = "https://github.com/mamba-org/rattler", branch = "m # rattler_solve = { path = "../rattler/crates/rattler_solve" } # rattler_shell = { path = "../rattler/crates/rattler_shell" } # rattler_virtual_packages = { path = "../rattler/crates/rattler_virtual_packages" } - +# rattler_networking = { path = "../rattler/crates/rattler_networking" } anyhow = "1.0.71" walkdir = "2.3.3" sha2 = "0.10.6" diff --git a/src/render/solver.rs b/src/render/solver.rs index 1c95bec4..998c3298 100644 --- a/src/render/solver.rs +++ b/src/render/solver.rs @@ -12,7 +12,9 @@ use rattler_conda_types::{ RepoDataRecord, }; use rattler_networking::{AuthenticatedClient, AuthenticationStorage}; -use rattler_repodata_gateway::fetch::{CacheResult, DownloadProgress, FetchRepoDataOptions}; +use rattler_repodata_gateway::fetch::{ + CacheResult, DownloadProgress, FetchRepoDataError, FetchRepoDataOptions, +}; use rattler_repodata_gateway::sparse::SparseRepoData; use rattler_solve::{libsolv_c::Solver, SolverImpl, SolverTask}; use reqwest::Client; @@ -133,6 +135,7 @@ pub async fn create_environment( &repodata_cache, download_client.clone(), multi_progress, + platform != Platform::NoArch, ) .await } @@ -142,6 +145,11 @@ pub async fn create_environment( .await // Collect into another iterator where we extract the first erroneous result .into_iter() + .filter_map(|res| match res { + Ok(Some(data)) => Some(Ok(data)), // If Ok contains Some, keep the data + Ok(None) => None, // If Ok contains None, discard it + Err(e) => Some(Err(e)), // If Err, keep it as is + }) .collect::, _>>()?; // Get the package names from the matchspecs so we can only load the package records that we need. @@ -479,7 +487,8 @@ async fn fetch_repo_data_records_with_progress( repodata_cache: &Path, client: AuthenticatedClient, multi_progress: indicatif::MultiProgress, -) -> Result { + allow_not_found: bool, +) -> anyhow::Result> { // Create a progress bar let progress_bar = multi_progress.add( indicatif::ProgressBar::new(1) @@ -508,8 +517,13 @@ async fn fetch_repo_data_records_with_progress( // Error out if an error occurred, but also update the progress bar let result = match result { Err(e) => { + if matches!(e, FetchRepoDataError::NotFound(_)) && allow_not_found { + progress_bar.set_style(errored_progress_style()); + progress_bar.finish_with_message("Not Found"); + return Ok(None); + } progress_bar.set_style(errored_progress_style()); - progress_bar.finish_with_message("Error"); + progress_bar.finish_with_message("404 not found"); return Err(e.into()); } Ok(result) => result, @@ -534,7 +548,7 @@ async fn fetch_repo_data_records_with_progress( CacheResult::CacheHit | CacheResult::CacheHitAfterFetch ); progress_bar.finish_with_message(if is_cache_hit { "Using cache" } else { "Done" }); - Ok(repodata) + Ok(Some(repodata)) } Ok(Err(err)) => { progress_bar.set_style(errored_progress_style());