From dbdc567edb1d1795de102b4abd338894a9cf6a20 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 1 Oct 2025 14:01:47 +0200 Subject: [PATCH 01/20] chore: avoid trailing whitespace in error message This messed with the tests, where my editor was chopping of trailing whitespace. While I'm in here, don't capitalize and parenthesize to make this line fit in better with the rest of our logging/errors. --- src/errors.rs | 4 ++-- tests/suite/cli_v2.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index df95c75b55..06aa59a71b 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -205,7 +205,7 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: & if toolchain.starts_with("nightly") { let _ = write!( buf, - "Sometimes not all components are available in any given nightly. " + "(sometimes not all components are available in any given nightly)" ); } } @@ -235,7 +235,7 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: & if toolchain.starts_with("nightly") { let _ = write!( buf, - "Sometimes not all components are available in any given nightly. " + "(sometimes not all components are available in any given nightly)" ); } } diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index fb2ab7bdc2..f9dc5937a9 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -1972,7 +1972,7 @@ async fn add_missing_component() { .with_stderr(snapbox::str![[r#" ... error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download for channel 'nightly' -Sometimes not all components are available in any given nightly. +(sometimes not all components are available in any given nightly) ... "#]]) .is_err(); From 41bebe2b0f5cc6f75be110a9f21f42b8e1bc676d Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:04:02 +0200 Subject: [PATCH 02/20] notifications: log directly when using download backends --- src/download/mod.rs | 14 ++++++++++---- src/notifications.rs | 11 +---------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/download/mod.rs b/src/download/mod.rs index 41912390b6..d777d2cb63 100644 --- a/src/download/mod.rs +++ b/src/download/mod.rs @@ -15,6 +15,12 @@ use anyhow::Context; use anyhow::anyhow; use sha2::Sha256; use thiserror::Error; +#[cfg(any( + feature = "curl-backend", + feature = "reqwest-rustls-tls", + feature = "reqwest-native-tls" +))] +use tracing::debug; #[cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))] use tracing::info; use tracing::warn; @@ -209,12 +215,12 @@ async fn download_file_( Err(_) => 180, }); - notify_handler(match backend { + match backend { #[cfg(feature = "curl-backend")] - Backend::Curl => Notification::UsingCurl, + Backend::Curl => debug!("downloading with curl"), #[cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))] - Backend::Reqwest(_) => Notification::UsingReqwest, - }); + Backend::Reqwest(_) => debug!("downloading with reqwest"), + }; let res = backend .download_to_path(url, path, resume_from_partial, Some(callback), timeout) diff --git a/src/notifications.rs b/src/notifications.rs index f011414efb..24ae89a312 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -46,9 +46,6 @@ pub(crate) enum Notification<'a> { /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), Error(String), - #[cfg(feature = "curl-backend")] - UsingCurl, - UsingReqwest, SetAutoInstall(&'a str), SetDefaultToolchain(Option<&'a ToolchainName>), SetOverrideToolchain(&'a Path, &'a str), @@ -102,10 +99,7 @@ impl Notification<'_> { | DownloadDataReceived(_, _) | DownloadFinished(_) | DownloadFailed(_) - | ResumingPartialDownload - | UsingReqwest => NotificationLevel::Debug, - #[cfg(feature = "curl-backend")] - UsingCurl => NotificationLevel::Debug, + | ResumingPartialDownload => NotificationLevel::Debug, Error(_) => NotificationLevel::Error, ToolchainDirectory(_) | LookingForToolchain(_) @@ -224,9 +218,6 @@ impl Display for Notification<'_> { DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), ResumingPartialDownload => write!(f, "resuming partial download"), - #[cfg(feature = "curl-backend")] - UsingCurl => write!(f, "downloading with curl"), - UsingReqwest => write!(f, "downloading with reqwest"), SetAutoInstall(auto) => write!(f, "auto install set to '{auto}'"), SetDefaultToolchain(None) => write!(f, "default toolchain unset"), SetDefaultToolchain(Some(name)) => write!(f, "default toolchain set to '{name}'"), From 3be758cc027dc8cfd87265f0348f7cb914ad06f8 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:06:14 +0200 Subject: [PATCH 03/20] notifications: log directly for valid checksums --- src/dist/download.rs | 8 ++++---- src/notifications.rs | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/dist/download.rs b/src/dist/download.rs index 3106fbcfbb..9c3551a19c 100644 --- a/src/dist/download.rs +++ b/src/dist/download.rs @@ -4,6 +4,7 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result, anyhow}; use sha2::{Digest, Sha256}; +use tracing::debug; use url::Url; use crate::dist::temp; @@ -50,7 +51,7 @@ impl<'a> DownloadCfg<'a> { let cached_result = file_hash(&target_file, self.notify_handler)?; if hash == cached_result { (self.notify_handler)(Notification::FileAlreadyDownloaded); - (self.notify_handler)(Notification::ChecksumValid(url.as_ref())); + debug!(url = url.as_ref(), "checksum passed"); return Ok(File { path: target_file }); } else { (self.notify_handler)(Notification::CachedFileChecksumFailed); @@ -105,8 +106,7 @@ impl<'a> DownloadCfg<'a> { .into()) } } else { - (self.notify_handler)(Notification::ChecksumValid(url.as_ref())); - + debug!(url = url.as_ref(), "checksum passed"); utils::rename("downloaded", &partial_file_path, &target_file, self.process)?; Ok(File { path: target_file }) } @@ -190,7 +190,7 @@ impl<'a> DownloadCfg<'a> { } .into()); } else { - (self.notify_handler)(Notification::ChecksumValid(url_str)); + debug!(url = url_str, "checksum passed"); } Ok(Some((file, partial_hash))) diff --git a/src/notifications.rs b/src/notifications.rs index 24ae89a312..9e2b24cab0 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -14,7 +14,6 @@ pub(crate) enum Notification<'a> { ComponentAlreadyInstalled(&'a str), CantReadUpdateHash(&'a Path), NoUpdateHash(&'a Path), - ChecksumValid(&'a str), FileAlreadyDownloaded, CachedFileChecksumFailed, MissingInstalledComponent(&'a str), @@ -75,10 +74,9 @@ impl Notification<'_> { pub(crate) fn level(&self) -> NotificationLevel { use self::Notification::*; match self { - ChecksumValid(_) - | NoUpdateHash(_) - | FileAlreadyDownloaded - | DownloadingLegacyManifest => NotificationLevel::Debug, + NoUpdateHash(_) | FileAlreadyDownloaded | DownloadingLegacyManifest => { + NotificationLevel::Debug + } DownloadingComponent(_, _, _, _) | InstallingComponent(_, _, _) | RemovingComponent(_, _, _) @@ -134,7 +132,6 @@ impl Display for Notification<'_> { path.display() ), NoUpdateHash(path) => write!(f, "no update hash at: '{}'", path.display()), - ChecksumValid(url) => write!(f, "checksum passed for {url}"), FileAlreadyDownloaded => write!(f, "reusing previously downloaded file"), CachedFileChecksumFailed => write!(f, "bad checksum for cached download"), MissingInstalledComponent(c) => { From 7f2803532b58400bdd3c2ab527be7c7b4f20a791 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:08:55 +0200 Subject: [PATCH 04/20] notifications: log directly when component is already installed --- src/dist/manifestation.rs | 23 ++++++++++++----------- src/notifications.rs | 3 --- tests/suite/cli_v2.rs | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/dist/manifestation.rs b/src/dist/manifestation.rs index 1319e70eb4..00557e4eda 100644 --- a/src/dist/manifestation.rs +++ b/src/dist/manifestation.rs @@ -122,13 +122,7 @@ impl Manifestation { // Create the lists of components needed for installation let config = self.read_config()?; - let mut update = Update::build_update( - self, - new_manifest, - &changes, - &config, - &download_cfg.notify_handler, - )?; + let mut update = Update::build_update(self, new_manifest, &changes, &config)?; if update.nothing_changes() { return Ok(UpdateStatus::Unchanged); @@ -539,7 +533,6 @@ impl Update { new_manifest: &Manifest, changes: &Changes, config: &Option, - notify_handler: &dyn Fn(Notification<'_>), ) -> Result { // The package to install. let rust_package = new_manifest.get_package("rust")?; @@ -601,9 +594,17 @@ impl Update { if !starting_list.contains(component) { result.components_to_install.push(component.clone()); } else if changes.explicit_add_components.contains(component) { - notify_handler(Notification::ComponentAlreadyInstalled( - &component.description(new_manifest), - )); + match &component.target { + Some(t) if t != &manifestation.target_triple => info!( + "component {} for target {} is up to date", + component.short_name(new_manifest), + t, + ), + _ => info!( + "component {} is up to date", + component.short_name(new_manifest) + ), + } } } } else { diff --git a/src/notifications.rs b/src/notifications.rs index 9e2b24cab0..62a2df2df9 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -11,7 +11,6 @@ use crate::{dist::ToolchainDesc, toolchain::ToolchainName, utils::notify::Notifi #[derive(Debug)] pub(crate) enum Notification<'a> { - ComponentAlreadyInstalled(&'a str), CantReadUpdateHash(&'a Path), NoUpdateHash(&'a Path), FileAlreadyDownloaded, @@ -81,7 +80,6 @@ impl Notification<'_> { | InstallingComponent(_, _, _) | RemovingComponent(_, _, _) | RemovingOldComponent(_, _, _) - | ComponentAlreadyInstalled(_) | DownloadingManifest(_) | SkippingNightlyMissingComponent(_, _, _) | RetryingDownload(_) @@ -125,7 +123,6 @@ impl Display for Notification<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::result::Result<(), fmt::Error> { use self::Notification::*; match self { - ComponentAlreadyInstalled(c) => write!(f, "component {c} is up to date"), CantReadUpdateHash(path) => write!( f, "can't read update hash file: '{}', can't skip update...", diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index f9dc5937a9..37780d81d1 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -1630,7 +1630,7 @@ async fn add_target_again() { .expect(["rustup", "target", "add", CROSS_ARCH1]) .await .with_stderr(snapbox::str![[r#" -info: component 'rust-std' for target '[CROSS_ARCH_I]' is up to date +info: component rust-std for target [CROSS_ARCH_I] is up to date "#]]) .is_ok(); @@ -2563,7 +2563,7 @@ async fn regression_2601() { .expect(["rustup", "component", "add", "rust-src"]) .await .with_stderr(snapbox::str![[r#" -info: component 'rust-src' is up to date +info: component rust-src is up to date "#]]) .is_ok(); From 1c75418c07f7428594524e0e5950df5ba2111f21 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:10:39 +0200 Subject: [PATCH 05/20] notifications: log directly when failing to update hash file --- src/dist/download.rs | 6 +++++- src/notifications.rs | 9 +-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/dist/download.rs b/src/dist/download.rs index 9c3551a19c..e9a98b5884 100644 --- a/src/dist/download.rs +++ b/src/dist/download.rs @@ -5,6 +5,7 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result, anyhow}; use sha2::{Digest, Sha256}; use tracing::debug; +use tracing::warn; use url::Url; use crate::dist::temp; @@ -160,7 +161,10 @@ impl<'a> DownloadCfg<'a> { return Ok(None); } } else { - (self.notify_handler)(Notification::CantReadUpdateHash(hash_file)); + warn!( + "can't read update hash {}, can't skip update", + hash_file.display() + ); } } else { (self.notify_handler)(Notification::NoUpdateHash(hash_file)); diff --git a/src/notifications.rs b/src/notifications.rs index 62a2df2df9..ae8385d1e8 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -11,7 +11,6 @@ use crate::{dist::ToolchainDesc, toolchain::ToolchainName, utils::notify::Notifi #[derive(Debug)] pub(crate) enum Notification<'a> { - CantReadUpdateHash(&'a Path), NoUpdateHash(&'a Path), FileAlreadyDownloaded, CachedFileChecksumFailed, @@ -84,8 +83,7 @@ impl Notification<'_> { | SkippingNightlyMissingComponent(_, _, _) | RetryingDownload(_) | DownloadedManifest(_, _) => NotificationLevel::Info, - CantReadUpdateHash(_) - | MissingInstalledComponent(_) + MissingInstalledComponent(_) | CachedFileChecksumFailed | ForcingUnavailableComponent(_) | StrayHash(_) => NotificationLevel::Warn, @@ -123,11 +121,6 @@ impl Display for Notification<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::result::Result<(), fmt::Error> { use self::Notification::*; match self { - CantReadUpdateHash(path) => write!( - f, - "can't read update hash file: '{}', can't skip update...", - path.display() - ), NoUpdateHash(path) => write!(f, "no update hash at: '{}'", path.display()), FileAlreadyDownloaded => write!(f, "reusing previously downloaded file"), CachedFileChecksumFailed => write!(f, "bad checksum for cached download"), From f4497dcd45a3d8945cf80df8b782a010de46ac75 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:11:53 +0200 Subject: [PATCH 06/20] notifications: log directly when hash file not found --- src/dist/download.rs | 2 +- src/notifications.rs | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/dist/download.rs b/src/dist/download.rs index e9a98b5884..e3918ae9ed 100644 --- a/src/dist/download.rs +++ b/src/dist/download.rs @@ -167,7 +167,7 @@ impl<'a> DownloadCfg<'a> { ); } } else { - (self.notify_handler)(Notification::NoUpdateHash(hash_file)); + debug!(file = %hash_file.display(), "no update hash file found"); } } diff --git a/src/notifications.rs b/src/notifications.rs index ae8385d1e8..1e8811b5d4 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -11,7 +11,6 @@ use crate::{dist::ToolchainDesc, toolchain::ToolchainName, utils::notify::Notifi #[derive(Debug)] pub(crate) enum Notification<'a> { - NoUpdateHash(&'a Path), FileAlreadyDownloaded, CachedFileChecksumFailed, MissingInstalledComponent(&'a str), @@ -72,9 +71,7 @@ impl Notification<'_> { pub(crate) fn level(&self) -> NotificationLevel { use self::Notification::*; match self { - NoUpdateHash(_) | FileAlreadyDownloaded | DownloadingLegacyManifest => { - NotificationLevel::Debug - } + FileAlreadyDownloaded | DownloadingLegacyManifest => NotificationLevel::Debug, DownloadingComponent(_, _, _, _) | InstallingComponent(_, _, _) | RemovingComponent(_, _, _) @@ -121,7 +118,6 @@ impl Display for Notification<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::result::Result<(), fmt::Error> { use self::Notification::*; match self { - NoUpdateHash(path) => write!(f, "no update hash at: '{}'", path.display()), FileAlreadyDownloaded => write!(f, "reusing previously downloaded file"), CachedFileChecksumFailed => write!(f, "bad checksum for cached download"), MissingInstalledComponent(c) => { From 16bd80714417c84571db99650f7a67afef5e59fa Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:14:41 +0200 Subject: [PATCH 07/20] notifications: log directly after failing to determine memory limit --- src/dist/component/package.rs | 8 +++----- src/notifications.rs | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/dist/component/package.rs b/src/dist/component/package.rs index eb17588464..ec79eae2c9 100644 --- a/src/dist/component/package.rs +++ b/src/dist/component/package.rs @@ -10,7 +10,7 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result, anyhow, bail}; use tar::EntryType; -use tracing::warn; +use tracing::{error, warn}; use crate::diskio::{CompletedIo, Executor, FileBuffer, IO_CHUNK_SIZE, Item, Kind, get_executor}; use crate::dist::component::components::*; @@ -290,10 +290,8 @@ fn unpack_without_first_dir( let entries = archive.entries()?; let effective_max_ram = match effective_limits::memory_limit() { Ok(ram) => Some(ram as usize), - Err(e) => { - if let Some(h) = cx.notify_handler { - h(Notification::Error(e.to_string())) - } + Err(error) => { + error!("can't determine memory limit: {error}"); None } }; diff --git a/src/notifications.rs b/src/notifications.rs index 1e8811b5d4..0613625d3c 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -41,7 +41,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - Error(String), SetAutoInstall(&'a str), SetDefaultToolchain(Option<&'a ToolchainName>), SetOverrideToolchain(&'a Path, &'a str), @@ -91,7 +90,6 @@ impl Notification<'_> { | DownloadFinished(_) | DownloadFailed(_) | ResumingPartialDownload => NotificationLevel::Debug, - Error(_) => NotificationLevel::Error, ToolchainDirectory(_) | LookingForToolchain(_) | InstallingToolchain(_) @@ -189,7 +187,6 @@ impl Display for Notification<'_> { write!(f, "Force-skipping unavailable component '{component}'") } RetryingDownload(url) => write!(f, "retrying download for '{url}'"), - Error(e) => write!(f, "error: '{e}'"), SetDefaultBufferSize(size) => write!( f, "using up to {} of RAM to unpack components", From 736226dd3807cd853c5eb4a702818335f7aac7f0 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:18:45 +0200 Subject: [PATCH 08/20] notifications: log directly on missing components --- src/dist/manifestation.rs | 21 +++++++-------------- src/dist/manifestation/tests.rs | 2 +- src/notifications.rs | 11 +++-------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/dist/manifestation.rs b/src/dist/manifestation.rs index 00557e4eda..a43c4466a1 100644 --- a/src/dist/manifestation.rs +++ b/src/dist/manifestation.rs @@ -10,7 +10,7 @@ use anyhow::{Context, Result, anyhow, bail}; use futures_util::stream::StreamExt; use std::sync::Arc; use tokio::sync::Semaphore; -use tracing::info; +use tracing::{info, warn}; use url::Url; use crate::dist::component::{ @@ -229,13 +229,7 @@ impl Manifestation { component.target.as_ref(), )); - tx = self.uninstall_component( - component, - new_manifest, - tx, - &download_cfg.notify_handler, - download_cfg.process, - )?; + tx = self.uninstall_component(component, new_manifest, tx, download_cfg.process)?; } // Install components @@ -313,7 +307,6 @@ impl Manifestation { &self, manifest: &Manifest, tmp_cx: &temp::Context, - notify_handler: &dyn Fn(Notification<'_>), process: &Process, ) -> Result<()> { let prefix = self.installation.prefix(); @@ -331,7 +324,7 @@ impl Manifestation { tx.remove_file("dist config", rel_config_path)?; for component in config.components { - tx = self.uninstall_component(&component, manifest, tx, notify_handler, process)?; + tx = self.uninstall_component(&component, manifest, tx, process)?; } tx.commit(); @@ -343,7 +336,6 @@ impl Manifestation { component: &Component, manifest: &Manifest, mut tx: Transaction<'a>, - notify_handler: &dyn Fn(Notification<'_>), process: &Process, ) -> Result> { // For historical reasons, the rust-installer component @@ -357,9 +349,10 @@ impl Manifestation { } else if let Some(c) = self.installation.find(short_name)? { tx = c.uninstall(tx, process)?; } else { - notify_handler(Notification::MissingInstalledComponent( - &component.short_name(manifest), - )); + warn!( + "component {} not found during uninstall", + component.short_name(manifest), + ); } Ok(tx) diff --git a/src/dist/manifestation/tests.rs b/src/dist/manifestation/tests.rs index 83689fd5ed..bf2090e2a5 100644 --- a/src/dist/manifestation/tests.rs +++ b/src/dist/manifestation/tests.rs @@ -540,7 +540,7 @@ impl TestContext { let manifestation = Manifestation::open(self.prefix.clone(), trip)?; let manifest = manifestation.load_manifest()?.unwrap(); - manifestation.uninstall(&manifest, &self.tmp_cx, &|_| (), &self.tp.process)?; + manifestation.uninstall(&manifest, &self.tmp_cx, &self.tp.process)?; Ok(()) } diff --git a/src/notifications.rs b/src/notifications.rs index 0613625d3c..e05b039131 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -13,7 +13,6 @@ use crate::{dist::ToolchainDesc, toolchain::ToolchainName, utils::notify::Notifi pub(crate) enum Notification<'a> { FileAlreadyDownloaded, CachedFileChecksumFailed, - MissingInstalledComponent(&'a str), /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), InstallingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>), @@ -79,10 +78,9 @@ impl Notification<'_> { | SkippingNightlyMissingComponent(_, _, _) | RetryingDownload(_) | DownloadedManifest(_, _) => NotificationLevel::Info, - MissingInstalledComponent(_) - | CachedFileChecksumFailed - | ForcingUnavailableComponent(_) - | StrayHash(_) => NotificationLevel::Warn, + CachedFileChecksumFailed | ForcingUnavailableComponent(_) | StrayHash(_) => { + NotificationLevel::Warn + } SetDefaultBufferSize(_) => NotificationLevel::Trace, DownloadingFile(_) | DownloadContentLengthReceived(_, _) @@ -118,9 +116,6 @@ impl Display for Notification<'_> { match self { FileAlreadyDownloaded => write!(f, "reusing previously downloaded file"), CachedFileChecksumFailed => write!(f, "bad checksum for cached download"), - MissingInstalledComponent(c) => { - write!(f, "during uninstall component {c} was not found") - } DownloadingComponent(c, h, t, _) => { if Some(h) == t.as_ref() || t.is_none() { write!(f, "downloading component '{c}'") From 111c5039a438ad3836cad5f57edbb21b615de075 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:24:52 +0200 Subject: [PATCH 09/20] notifications: log directly when installing components --- src/dist/manifestation.rs | 23 ++++++++++++----------- src/notifications.rs | 9 --------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/dist/manifestation.rs b/src/dist/manifestation.rs index a43c4466a1..3f7fb8d975 100644 --- a/src/dist/manifestation.rs +++ b/src/dist/manifestation.rs @@ -242,11 +242,17 @@ impl Manifestation { let short_pkg_name = component.short_name_in_manifest(); let short_name = component.short_name(new_manifest); - (download_cfg.notify_handler)(Notification::InstallingComponent( - &short_name, - &self.target_triple, - component.target.as_ref(), - )); + match &component.target { + Some(t) if t != &self.target_triple => { + info!("installing component {short_name}"); + } + _ => { + info!( + "installing component {short_name} for target {}", + self.target_triple + ) + } + } let cx = PackageContext { tmp_cx, @@ -450,12 +456,7 @@ impl Manifestation { let (installer_file, installer_hash) = dl.unwrap(); let prefix = self.installation.prefix(); - - notify_handler(Notification::InstallingComponent( - "rust", - &self.target_triple, - Some(&self.target_triple), - )); + info!("installing component rust"); // Begin transaction let mut tx = Transaction::new(prefix, tmp_cx, process); diff --git a/src/notifications.rs b/src/notifications.rs index e05b039131..15f70ac4ff 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -15,7 +15,6 @@ pub(crate) enum Notification<'a> { CachedFileChecksumFailed, /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), - InstallingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>), RemovingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>), RemovingOldComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>), DownloadingManifest(&'a str), @@ -71,7 +70,6 @@ impl Notification<'_> { match self { FileAlreadyDownloaded | DownloadingLegacyManifest => NotificationLevel::Debug, DownloadingComponent(_, _, _, _) - | InstallingComponent(_, _, _) | RemovingComponent(_, _, _) | RemovingOldComponent(_, _, _) | DownloadingManifest(_) @@ -123,13 +121,6 @@ impl Display for Notification<'_> { write!(f, "downloading component '{}' for '{}'", c, t.unwrap()) } } - InstallingComponent(c, h, t) => { - if Some(h) == t.as_ref() || t.is_none() { - write!(f, "installing component '{c}'") - } else { - write!(f, "installing component '{}' for '{}'", c, t.unwrap()) - } - } RemovingComponent(c, h, t) => { if Some(h) == t.as_ref() || t.is_none() { write!(f, "removing component '{c}'") From 19ce86371c25804cf50aa9540714f753e40d854d Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:28:54 +0200 Subject: [PATCH 10/20] notifications: log directly when removing components --- src/dist/manifestation.rs | 35 +++++++++++++++++++++++++---------- src/notifications.rs | 23 ----------------------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/dist/manifestation.rs b/src/dist/manifestation.rs index 3f7fb8d975..53f0421747 100644 --- a/src/dist/manifestation.rs +++ b/src/dist/manifestation.rs @@ -218,16 +218,31 @@ impl Manifestation { // Uninstall components for component in &update.components_to_uninstall { - let notification = if implicit_modify { - Notification::RemovingOldComponent - } else { - Notification::RemovingComponent - }; - (download_cfg.notify_handler)(notification( - &component.short_name(new_manifest), - &self.target_triple, - component.target.as_ref(), - )); + match (implicit_modify, &component.target) { + (true, Some(t)) if t != &self.target_triple => { + info!( + "removing previous version of component {} for target {}", + component.short_name(new_manifest), + t + ); + } + (false, Some(t)) if t != &self.target_triple => { + info!( + "removing component {} for target {}", + component.short_name(new_manifest), + t + ); + } + (true, _) => { + info!( + "removing previous version of component {}", + component.short_name(new_manifest), + ); + } + (false, _) => { + info!("removing component {}", component.short_name(new_manifest)); + } + } tx = self.uninstall_component(component, new_manifest, tx, download_cfg.process)?; } diff --git a/src/notifications.rs b/src/notifications.rs index 15f70ac4ff..656cded3ab 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -15,8 +15,6 @@ pub(crate) enum Notification<'a> { CachedFileChecksumFailed, /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), - RemovingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>), - RemovingOldComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>), DownloadingManifest(&'a str), DownloadedManifest(&'a str, Option<&'a str>), DownloadingLegacyManifest, @@ -70,8 +68,6 @@ impl Notification<'_> { match self { FileAlreadyDownloaded | DownloadingLegacyManifest => NotificationLevel::Debug, DownloadingComponent(_, _, _, _) - | RemovingComponent(_, _, _) - | RemovingOldComponent(_, _, _) | DownloadingManifest(_) | SkippingNightlyMissingComponent(_, _, _) | RetryingDownload(_) @@ -121,25 +117,6 @@ impl Display for Notification<'_> { write!(f, "downloading component '{}' for '{}'", c, t.unwrap()) } } - RemovingComponent(c, h, t) => { - if Some(h) == t.as_ref() || t.is_none() { - write!(f, "removing component '{c}'") - } else { - write!(f, "removing component '{}' for '{}'", c, t.unwrap()) - } - } - RemovingOldComponent(c, h, t) => { - if Some(h) == t.as_ref() || t.is_none() { - write!(f, "removing previous version of component '{c}'") - } else { - write!( - f, - "removing previous version of component '{}' for '{}'", - c, - t.unwrap() - ) - } - } DownloadingManifest(t) => write!(f, "syncing channel updates for '{t}'"), DownloadedManifest(date, Some(version)) => { write!(f, "latest update on {date}, rust version {version}") From 682e55ee3403b9e0f892d13c8308b244d9407116 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:30:15 +0200 Subject: [PATCH 11/20] notifications: log directly for manifest downloads --- src/dist/mod.rs | 2 +- src/notifications.rs | 3 --- tests/suite/cli_exact.rs | 24 ++++++++++++------------ tests/suite/cli_rustup.rs | 24 ++++++++++++------------ tests/suite/cli_self_upd.rs | 8 ++++---- tests/suite/cli_v1.rs | 2 +- tests/suite/cli_v2.rs | 6 +++--- 7 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/dist/mod.rs b/src/dist/mod.rs index 57bc1b91f0..b8352172b6 100644 --- a/src/dist/mod.rs +++ b/src/dist/mod.rs @@ -1072,7 +1072,7 @@ async fn try_update_from_dist_( let manifestation = Manifestation::open(prefix.clone(), toolchain.target.clone())?; // TODO: Add a notification about which manifest version is going to be used - (download.notify_handler)(Notification::DownloadingManifest(&toolchain_str)); + info!("syncing channel updates for {toolchain_str}"); match dl_v2_manifest( download, // Even if manifest has not changed, we must continue to install requested components. diff --git a/src/notifications.rs b/src/notifications.rs index 656cded3ab..8401523322 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -15,7 +15,6 @@ pub(crate) enum Notification<'a> { CachedFileChecksumFailed, /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), - DownloadingManifest(&'a str), DownloadedManifest(&'a str, Option<&'a str>), DownloadingLegacyManifest, SkippingNightlyMissingComponent(&'a ToolchainDesc, &'a Manifest, &'a [Component]), @@ -68,7 +67,6 @@ impl Notification<'_> { match self { FileAlreadyDownloaded | DownloadingLegacyManifest => NotificationLevel::Debug, DownloadingComponent(_, _, _, _) - | DownloadingManifest(_) | SkippingNightlyMissingComponent(_, _, _) | RetryingDownload(_) | DownloadedManifest(_, _) => NotificationLevel::Info, @@ -117,7 +115,6 @@ impl Display for Notification<'_> { write!(f, "downloading component '{}' for '{}'", c, t.unwrap()) } } - DownloadingManifest(t) => write!(f, "syncing channel updates for '{t}'"), DownloadedManifest(date, Some(version)) => { write!(f, "latest update on {date}, rust version {version}") } diff --git a/tests/suite/cli_exact.rs b/tests/suite/cli_exact.rs index 020b931927..a210b3c57f 100644 --- a/tests/suite/cli_exact.rs +++ b/tests/suite/cli_exact.rs @@ -20,7 +20,7 @@ async fn update_once() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component[..] ... @@ -67,7 +67,7 @@ rustup - Update available : [CURRENT_VERSION] -> [TEST_VERSION] "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component[..] ... @@ -110,7 +110,7 @@ async fn update_once_and_self_update() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component[..] ... @@ -153,7 +153,7 @@ async fn update_again() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-[HOST_TRIPLE] "#]]); cx.config @@ -167,7 +167,7 @@ info: syncing channel updates for 'nightly-[HOST_TRIPLE]' "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-[HOST_TRIPLE] "#]]); } @@ -321,7 +321,7 @@ async fn default() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component[..] ... @@ -584,7 +584,7 @@ async fn update_no_manifest() { .is_err() .with_stdout(snapbox::str![[""]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-2016-01-01-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-2016-01-01-[HOST_TRIPLE] error: no release found for 'nightly-2016-01-01' "#]]); @@ -867,10 +867,10 @@ async fn install_unreleased_component() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-[HOST_TRIPLE] info: latest update on 2019-09-13, rust version 1.37.0 (hash-nightly-2) info: skipping nightly which is missing installed component 'rust-std-[MULTI_ARCH_I]' -info: syncing channel updates for 'nightly-2019-09-12-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-2019-09-12-[HOST_TRIPLE] "#]]); @@ -887,13 +887,13 @@ info: syncing channel updates for 'nightly-2019-09-12-[HOST_TRIPLE]' "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-[HOST_TRIPLE] info: latest update on 2019-09-14, rust version 1.37.0 (hash-nightly-3) info: skipping nightly which is missing installed component 'rls' -info: syncing channel updates for 'nightly-2019-09-13-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-2019-09-13-[HOST_TRIPLE] info: latest update on 2019-09-13, rust version 1.37.0 (hash-nightly-2) info: skipping nightly which is missing installed component 'rust-std-[MULTI_ARCH_I]' -info: syncing channel updates for 'nightly-2019-09-12-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-2019-09-12-[HOST_TRIPLE] "#]]); } diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index 407585a1d1..f7b13a6bcc 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -33,7 +33,7 @@ async fn rustup_stable() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'stable-[HOST_TRIPLE]' +info: syncing channel updates for stable-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... @@ -97,7 +97,7 @@ async fn rustup_stable_no_change() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'stable-[HOST_TRIPLE]' +info: syncing channel updates for stable-[HOST_TRIPLE] info: cleaning up downloads & tmp directories "#]]) @@ -129,15 +129,15 @@ async fn rustup_all_channels() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'stable-[HOST_TRIPLE]' +info: syncing channel updates for stable-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... -info: syncing channel updates for 'beta-[HOST_TRIPLE]' +info: syncing channel updates for beta-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.2.0 (hash-beta-1.2.0) info: downloading component[..] ... -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component[..] ... @@ -206,12 +206,12 @@ async fn rustup_some_channels_up_to_date() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'stable-[HOST_TRIPLE]' +info: syncing channel updates for stable-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... -info: syncing channel updates for 'beta-[HOST_TRIPLE]' -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates for beta-[HOST_TRIPLE] +info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component[..] ... @@ -282,7 +282,7 @@ async fn default() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component[..] ... @@ -1706,7 +1706,7 @@ channel = "nightly" .await .extend_redactions([("[TOOLCHAIN_FILE]", &toolchain_file)]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component[..] ... @@ -3616,7 +3616,7 @@ async fn dont_warn_on_partial_build() { .await .with_stderr(snapbox::str![[r#" ... -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates for nightly-[HOST_TRIPLE] ... "#]]) .is_ok() @@ -3717,7 +3717,7 @@ async fn custom_toolchain_with_components_toolchains_profile_does_not_err() { ]) .await .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component[..] ... diff --git a/tests/suite/cli_self_upd.rs b/tests/suite/cli_self_upd.rs index 53ff97415a..465b65c3fb 100644 --- a/tests/suite/cli_self_upd.rs +++ b/tests/suite/cli_self_upd.rs @@ -70,7 +70,7 @@ async fn install_bins_to_cargo_home() { "#]]) .with_stderr(snapbox::str![[r#" ... -info: syncing channel updates for 'stable-[HOST_TRIPLE]' +info: syncing channel updates for stable-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... @@ -115,12 +115,12 @@ async fn proxies_are_relative_symlinks() { "#]]) .with_stderr(snapbox::str![[r#" ... -info: syncing channel updates for 'stable-[HOST_TRIPLE]' +info: syncing channel updates for stable-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... info: default toolchain set to 'stable-[HOST_TRIPLE]' -... + "#]]) .is_ok(); @@ -692,7 +692,7 @@ async fn rustup_self_update_exact() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'stable-[HOST_TRIPLE]' +info: syncing channel updates for stable-[HOST_TRIPLE] info: checking for self-update (current version: [CURRENT_VERSION]) info: downloading self-update (new version: [TEST_VERSION]) info: cleaning up downloads & tmp directories diff --git a/tests/suite/cli_v1.rs b/tests/suite/cli_v1.rs index 40fae3c9b1..194e6b73c3 100644 --- a/tests/suite/cli_v1.rs +++ b/tests/suite/cli_v1.rs @@ -278,7 +278,7 @@ async fn remove_override_toolchain_err_handling() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'beta-[HOST_TRIPLE]' +info: syncing channel updates for beta-[HOST_TRIPLE] ... "#]]) .is_ok(); diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index 37780d81d1..3c13fb93ee 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -485,7 +485,7 @@ async fn remove_override_toolchain_err_handling() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'beta-[HOST_TRIPLE]' +info: syncing channel updates fpr beta-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.2.0 (hash-beta-1.2.0) info: downloading component[..] ... @@ -518,7 +518,7 @@ async fn file_override_toolchain_err_handling() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'beta-[HOST_TRIPLE]' +info: syncing channel updates fpr beta-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.2.0 (hash-beta-1.2.0) info: downloading component[..] ... @@ -2458,7 +2458,7 @@ async fn run_with_install_flag_against_unavailable_component() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates for 'nightly-[HOST_TRIPLE]' +info: syncing channel updates fpr nightly-[HOST_TRIPLE] info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) warn: Force-skipping unavailable component 'rust-std-[HOST_TRIPLE]' info: downloading component[..] From 8262c18f9adfde28545c08ce58b856d42cf8a2af Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:39:06 +0200 Subject: [PATCH 12/20] notifications: log directly for downloaded manifests --- src/dist/mod.rs | 8 ++++---- src/notifications.rs | 10 +--------- tests/suite/cli_exact.rs | 38 ++++++++++++++++++------------------- tests/suite/cli_rustup.rs | 18 +++++++++--------- tests/suite/cli_self_upd.rs | 4 ++-- tests/suite/cli_v2.rs | 12 ++++++------ 6 files changed, 41 insertions(+), 49 deletions(-) diff --git a/src/dist/mod.rs b/src/dist/mod.rs index b8352172b6..4461ddee19 100644 --- a/src/dist/mod.rs +++ b/src/dist/mod.rs @@ -1088,10 +1088,10 @@ async fn try_update_from_dist_( .await { Ok(Some((m, hash))) => { - (download.notify_handler)(Notification::DownloadedManifest( - &m.date, - m.get_rust_version().ok(), - )); + match m.get_rust_version() { + Ok(version) => info!("latest update on {} for version {version}", m.date), + Err(_) => info!("latest update on {}", m.date), + } let profile_components = match profile { Some(profile) => m.get_profile_components(profile, &toolchain.target)?, diff --git a/src/notifications.rs b/src/notifications.rs index 8401523322..c92864a8f9 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -15,7 +15,6 @@ pub(crate) enum Notification<'a> { CachedFileChecksumFailed, /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), - DownloadedManifest(&'a str, Option<&'a str>), DownloadingLegacyManifest, SkippingNightlyMissingComponent(&'a ToolchainDesc, &'a Manifest, &'a [Component]), ForcingUnavailableComponent(&'a str), @@ -68,8 +67,7 @@ impl Notification<'_> { FileAlreadyDownloaded | DownloadingLegacyManifest => NotificationLevel::Debug, DownloadingComponent(_, _, _, _) | SkippingNightlyMissingComponent(_, _, _) - | RetryingDownload(_) - | DownloadedManifest(_, _) => NotificationLevel::Info, + | RetryingDownload(_) => NotificationLevel::Info, CachedFileChecksumFailed | ForcingUnavailableComponent(_) | StrayHash(_) => { NotificationLevel::Warn } @@ -115,12 +113,6 @@ impl Display for Notification<'_> { write!(f, "downloading component '{}' for '{}'", c, t.unwrap()) } } - DownloadedManifest(date, Some(version)) => { - write!(f, "latest update on {date}, rust version {version}") - } - DownloadedManifest(date, None) => { - write!(f, "latest update on {date}, no rust version") - } DownloadingLegacyManifest => write!(f, "manifest not found. trying legacy manifest"), StrayHash(path) => write!( f, diff --git a/tests/suite/cli_exact.rs b/tests/suite/cli_exact.rs index a210b3c57f..a9960c273b 100644 --- a/tests/suite/cli_exact.rs +++ b/tests/suite/cli_exact.rs @@ -20,8 +20,8 @@ async fn update_once() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: syncing channel updates for nightly-[HOST_TRIPLE] +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... info: default toolchain set to 'nightly-[HOST_TRIPLE]' @@ -67,8 +67,8 @@ rustup - Update available : [CURRENT_VERSION] -> [TEST_VERSION] "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: syncing channel updates for nightly-[HOST_TRIPLE] +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... "#]]); @@ -110,8 +110,8 @@ async fn update_once_and_self_update() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: syncing channel updates for nightly-[HOST_TRIPLE] +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... info: checking for self-update (current version: [CURRENT_VERSION]) @@ -153,7 +153,7 @@ async fn update_again() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-[HOST_TRIPLE] +info: syncing channel updates for nightly-[HOST_TRIPLE] "#]]); cx.config @@ -167,7 +167,7 @@ info: syncing channel updates fpr nightly-[HOST_TRIPLE] "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-[HOST_TRIPLE] +info: syncing channel updates for nightly-[HOST_TRIPLE] "#]]); } @@ -321,8 +321,8 @@ async fn default() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: syncing channel updates for nightly-[HOST_TRIPLE] +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... info: default toolchain set to 'nightly-[HOST_TRIPLE]' @@ -584,7 +584,7 @@ async fn update_no_manifest() { .is_err() .with_stdout(snapbox::str![[""]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-2016-01-01-[HOST_TRIPLE] +info: syncing channel updates for nightly-2016-01-01-[HOST_TRIPLE] error: no release found for 'nightly-2016-01-01' "#]]); @@ -867,10 +867,10 @@ async fn install_unreleased_component() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-[HOST_TRIPLE] -info: latest update on 2019-09-13, rust version 1.37.0 (hash-nightly-2) +info: syncing channel updates for nightly-[HOST_TRIPLE] +info: latest update on 2019-09-13 for version 1.37.0 (hash-nightly-2) info: skipping nightly which is missing installed component 'rust-std-[MULTI_ARCH_I]' -info: syncing channel updates fpr nightly-2019-09-12-[HOST_TRIPLE] +info: syncing channel updates for nightly-2019-09-12-[HOST_TRIPLE] "#]]); @@ -887,13 +887,13 @@ info: syncing channel updates fpr nightly-2019-09-12-[HOST_TRIPLE] "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-[HOST_TRIPLE] -info: latest update on 2019-09-14, rust version 1.37.0 (hash-nightly-3) +info: syncing channel updates for nightly-[HOST_TRIPLE] +info: latest update on 2019-09-14 for version 1.37.0 (hash-nightly-3) info: skipping nightly which is missing installed component 'rls' -info: syncing channel updates fpr nightly-2019-09-13-[HOST_TRIPLE] -info: latest update on 2019-09-13, rust version 1.37.0 (hash-nightly-2) +info: syncing channel updates for nightly-2019-09-13-[HOST_TRIPLE] +info: latest update on 2019-09-13 for version 1.37.0 (hash-nightly-2) info: skipping nightly which is missing installed component 'rust-std-[MULTI_ARCH_I]' -info: syncing channel updates fpr nightly-2019-09-12-[HOST_TRIPLE] +info: syncing channel updates for nightly-2019-09-12-[HOST_TRIPLE] "#]]); } diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index f7b13a6bcc..b4cfddea3a 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -34,7 +34,7 @@ async fn rustup_stable() { "#]]) .with_stderr(snapbox::str![[r#" info: syncing channel updates for stable-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) +info: latest update on 2015-01-02 for version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... info: cleaning up downloads & tmp directories @@ -130,15 +130,15 @@ async fn rustup_all_channels() { "#]]) .with_stderr(snapbox::str![[r#" info: syncing channel updates for stable-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) +info: latest update on 2015-01-02 for version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... info: syncing channel updates for beta-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.2.0 (hash-beta-1.2.0) +info: latest update on 2015-01-02 for version 1.2.0 (hash-beta-1.2.0) info: downloading component[..] ... info: syncing channel updates for nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... info: cleaning up downloads & tmp directories @@ -207,12 +207,12 @@ async fn rustup_some_channels_up_to_date() { "#]]) .with_stderr(snapbox::str![[r#" info: syncing channel updates for stable-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) +info: latest update on 2015-01-02 for version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... info: syncing channel updates for beta-[HOST_TRIPLE] info: syncing channel updates for nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... info: cleaning up downloads & tmp directories @@ -283,7 +283,7 @@ async fn default() { "#]]) .with_stderr(snapbox::str![[r#" info: syncing channel updates for nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... info: default toolchain set to 'nightly-[HOST_TRIPLE]' @@ -1707,7 +1707,7 @@ channel = "nightly" .extend_redactions([("[TOOLCHAIN_FILE]", &toolchain_file)]) .with_stderr(snapbox::str![[r#" info: syncing channel updates for nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... info: the active toolchain `nightly-[HOST_TRIPLE]` has been installed @@ -3718,7 +3718,7 @@ async fn custom_toolchain_with_components_toolchains_profile_does_not_err() { .await .with_stderr(snapbox::str![[r#" info: syncing channel updates for nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... info: default toolchain set to 'nightly-[HOST_TRIPLE]' diff --git a/tests/suite/cli_self_upd.rs b/tests/suite/cli_self_upd.rs index 465b65c3fb..006d52e61e 100644 --- a/tests/suite/cli_self_upd.rs +++ b/tests/suite/cli_self_upd.rs @@ -71,7 +71,7 @@ async fn install_bins_to_cargo_home() { .with_stderr(snapbox::str![[r#" ... info: syncing channel updates for stable-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) +info: latest update on 2015-01-02 for version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... info: default toolchain set to 'stable-[HOST_TRIPLE]' @@ -116,7 +116,7 @@ async fn proxies_are_relative_symlinks() { .with_stderr(snapbox::str![[r#" ... info: syncing channel updates for stable-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) +info: latest update on 2015-01-02 for version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... info: default toolchain set to 'stable-[HOST_TRIPLE]' diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index 3c13fb93ee..a7691c8889 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -485,8 +485,8 @@ async fn remove_override_toolchain_err_handling() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr beta-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.2.0 (hash-beta-1.2.0) +info: syncing channel updates for beta-[HOST_TRIPLE] +info: latest update on 2015-01-02 for version 1.2.0 (hash-beta-1.2.0) info: downloading component[..] ... "#]]) @@ -518,8 +518,8 @@ async fn file_override_toolchain_err_handling() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr beta-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.2.0 (hash-beta-1.2.0) +info: syncing channel updates for beta-[HOST_TRIPLE] +info: latest update on 2015-01-02 for version 1.2.0 (hash-beta-1.2.0) info: downloading component[..] ... "#]]) @@ -2458,8 +2458,8 @@ async fn run_with_install_flag_against_unavailable_component() { "#]]) .with_stderr(snapbox::str![[r#" -info: syncing channel updates fpr nightly-[HOST_TRIPLE] -info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: syncing channel updates for nightly-[HOST_TRIPLE] +info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) warn: Force-skipping unavailable component 'rust-std-[HOST_TRIPLE]' info: downloading component[..] ... From fd6b456af286b3587cb61bd5c48b6ec148b7d05d Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:40:32 +0200 Subject: [PATCH 13/20] notifications: log directly when downloading legacy manifests --- src/dist/mod.rs | 4 ++-- src/notifications.rs | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/dist/mod.rs b/src/dist/mod.rs index 4461ddee19..e28825f329 100644 --- a/src/dist/mod.rs +++ b/src/dist/mod.rs @@ -11,7 +11,7 @@ use itertools::Itertools; use regex::Regex; use serde::{Deserialize, Serialize}; use thiserror::Error as ThisError; -use tracing::{info, warn}; +use tracing::{debug, info, warn}; use crate::{ config::{Cfg, dist_root_server}, @@ -1173,7 +1173,7 @@ async fn try_update_from_dist_( Some(RustupError::ChecksumFailed { .. }) => return Ok(None), Some(RustupError::DownloadNotExists { .. }) => { // Proceed to try v1 as a fallback - (download.notify_handler)(Notification::DownloadingLegacyManifest) + debug!("manifest not found; trying legacy manifest"); } _ => return Err(err), } diff --git a/src/notifications.rs b/src/notifications.rs index c92864a8f9..fd466177e8 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -15,7 +15,6 @@ pub(crate) enum Notification<'a> { CachedFileChecksumFailed, /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), - DownloadingLegacyManifest, SkippingNightlyMissingComponent(&'a ToolchainDesc, &'a Manifest, &'a [Component]), ForcingUnavailableComponent(&'a str), StrayHash(&'a Path), @@ -64,7 +63,7 @@ impl Notification<'_> { pub(crate) fn level(&self) -> NotificationLevel { use self::Notification::*; match self { - FileAlreadyDownloaded | DownloadingLegacyManifest => NotificationLevel::Debug, + FileAlreadyDownloaded => NotificationLevel::Debug, DownloadingComponent(_, _, _, _) | SkippingNightlyMissingComponent(_, _, _) | RetryingDownload(_) => NotificationLevel::Info, @@ -113,7 +112,6 @@ impl Display for Notification<'_> { write!(f, "downloading component '{}' for '{}'", c, t.unwrap()) } } - DownloadingLegacyManifest => write!(f, "manifest not found. trying legacy manifest"), StrayHash(path) => write!( f, "removing stray hash found at '{}' in order to continue", From 893594ba09ec5f75b55d27d348466743af4c0c57 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:48:00 +0200 Subject: [PATCH 14/20] notifications: log directly on missing components --- src/dist/mod.rs | 17 ++++++++++++----- src/notifications.rs | 22 +--------------------- tests/suite/cli_exact.rs | 6 +++--- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/dist/mod.rs b/src/dist/mod.rs index e28825f329..4acd5f7d5e 100644 --- a/src/dist/mod.rs +++ b/src/dist/mod.rs @@ -990,11 +990,18 @@ pub(crate) async fn update_from_dist( let cause = e.downcast_ref::(); match cause { Some(DistError::ToolchainComponentsMissing(components, manifest, ..)) => { - (opts.dl_cfg.notify_handler)(Notification::SkippingNightlyMissingComponent( - &toolchain, - current_manifest.as_ref().unwrap_or(manifest), - components, - )); + let plural = if components.len() > 1 { "s" } else { "" }; + let manifest = current_manifest.as_ref().unwrap_or(manifest); + let components = components + .iter() + .map( + |component| match component.target.as_ref() == Some(&toolchain.target) { + true => component.short_name(manifest), + false => component.name(manifest), + }, + ) + .join(", "); + info!("skipping nightly with missing component{plural}: {components}"); if first_err.is_none() { first_err = Some(e); diff --git a/src/notifications.rs b/src/notifications.rs index fd466177e8..d73b4798bf 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -4,7 +4,6 @@ use std::path::{Path, PathBuf}; use url::Url; use crate::dist::TargetTriple; -use crate::dist::manifest::{Component, Manifest}; use crate::settings::MetadataVersion; use crate::utils::units; use crate::{dist::ToolchainDesc, toolchain::ToolchainName, utils::notify::NotificationLevel}; @@ -15,7 +14,6 @@ pub(crate) enum Notification<'a> { CachedFileChecksumFailed, /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), - SkippingNightlyMissingComponent(&'a ToolchainDesc, &'a Manifest, &'a [Component]), ForcingUnavailableComponent(&'a str), StrayHash(&'a Path), RetryingDownload(&'a str), @@ -64,9 +62,7 @@ impl Notification<'_> { use self::Notification::*; match self { FileAlreadyDownloaded => NotificationLevel::Debug, - DownloadingComponent(_, _, _, _) - | SkippingNightlyMissingComponent(_, _, _) - | RetryingDownload(_) => NotificationLevel::Info, + DownloadingComponent(_, _, _, _) | RetryingDownload(_) => NotificationLevel::Info, CachedFileChecksumFailed | ForcingUnavailableComponent(_) | StrayHash(_) => { NotificationLevel::Warn } @@ -117,22 +113,6 @@ impl Display for Notification<'_> { "removing stray hash found at '{}' in order to continue", path.display() ), - SkippingNightlyMissingComponent(toolchain, manifest, components) => write!( - f, - "skipping nightly which is missing installed component{} '{}'", - if components.len() > 1 { "s" } else { "" }, - components - .iter() - .map(|component| { - if component.target.as_ref() != Some(&toolchain.target) { - component.name(manifest) - } else { - component.short_name(manifest) - } - }) - .collect::>() - .join("', '") - ), ForcingUnavailableComponent(component) => { write!(f, "Force-skipping unavailable component '{component}'") } diff --git a/tests/suite/cli_exact.rs b/tests/suite/cli_exact.rs index a9960c273b..d993da11fb 100644 --- a/tests/suite/cli_exact.rs +++ b/tests/suite/cli_exact.rs @@ -869,7 +869,7 @@ async fn install_unreleased_component() { .with_stderr(snapbox::str![[r#" info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2019-09-13 for version 1.37.0 (hash-nightly-2) -info: skipping nightly which is missing installed component 'rust-std-[MULTI_ARCH_I]' +info: skipping nightly with missing component: rust-std-[MULTI_ARCH_I] info: syncing channel updates for nightly-2019-09-12-[HOST_TRIPLE] "#]]); @@ -889,10 +889,10 @@ info: syncing channel updates for nightly-2019-09-12-[HOST_TRIPLE] .with_stderr(snapbox::str![[r#" info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2019-09-14 for version 1.37.0 (hash-nightly-3) -info: skipping nightly which is missing installed component 'rls' +info: skipping nightly with missing component: rls info: syncing channel updates for nightly-2019-09-13-[HOST_TRIPLE] info: latest update on 2019-09-13 for version 1.37.0 (hash-nightly-2) -info: skipping nightly which is missing installed component 'rust-std-[MULTI_ARCH_I]' +info: skipping nightly with missing component: rust-std-[MULTI_ARCH_I] info: syncing channel updates for nightly-2019-09-12-[HOST_TRIPLE] "#]]); From 27497005e5c3b955b280951cf4736ac33d5af971 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:50:26 +0200 Subject: [PATCH 15/20] notifications: log directly when skipping components --- src/dist/manifestation.rs | 14 +++++++++++--- src/notifications.rs | 8 +------- tests/suite/cli_inst_interactive.rs | 2 +- tests/suite/cli_rustup.rs | 2 +- tests/suite/cli_v2.rs | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/dist/manifestation.rs b/src/dist/manifestation.rs index 53f0421747..14aaacbf18 100644 --- a/src/dist/manifestation.rs +++ b/src/dist/manifestation.rs @@ -137,9 +137,17 @@ impl Manifestation { e.downcast::() { for component in &components { - (download_cfg.notify_handler)(Notification::ForcingUnavailableComponent( - &component.name(new_manifest), - )); + match &component.target { + Some(t) if t != &self.target_triple => warn!( + "skipping unavailable component {} for target {}", + component.short_name(new_manifest), + t + ), + _ => warn!( + "skipping unavailable component {}", + component.short_name(new_manifest) + ), + } } update.drop_components_to_install(&components); } diff --git a/src/notifications.rs b/src/notifications.rs index d73b4798bf..e899fe1991 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -14,7 +14,6 @@ pub(crate) enum Notification<'a> { CachedFileChecksumFailed, /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), - ForcingUnavailableComponent(&'a str), StrayHash(&'a Path), RetryingDownload(&'a str), DownloadingFile(&'a Url), @@ -63,9 +62,7 @@ impl Notification<'_> { match self { FileAlreadyDownloaded => NotificationLevel::Debug, DownloadingComponent(_, _, _, _) | RetryingDownload(_) => NotificationLevel::Info, - CachedFileChecksumFailed | ForcingUnavailableComponent(_) | StrayHash(_) => { - NotificationLevel::Warn - } + CachedFileChecksumFailed | StrayHash(_) => NotificationLevel::Warn, SetDefaultBufferSize(_) => NotificationLevel::Trace, DownloadingFile(_) | DownloadContentLengthReceived(_, _) @@ -113,9 +110,6 @@ impl Display for Notification<'_> { "removing stray hash found at '{}' in order to continue", path.display() ), - ForcingUnavailableComponent(component) => { - write!(f, "Force-skipping unavailable component '{component}'") - } RetryingDownload(url) => write!(f, "retrying download for '{url}'"), SetDefaultBufferSize(size) => write!( f, diff --git a/tests/suite/cli_inst_interactive.rs b/tests/suite/cli_inst_interactive.rs index 7a82ac187e..6b1e31bfd2 100644 --- a/tests/suite/cli_inst_interactive.rs +++ b/tests/suite/cli_inst_interactive.rs @@ -478,7 +478,7 @@ async fn install_forces_and_skips_rls() { .is_ok() .with_stderr(snapbox::str![[r#" ... -warn: Force-skipping unavailable component 'rls-[HOST_TRIPLE]' +warn: skipping unavailable component rls ... "#]]); } diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index b4cfddea3a..23765d0405 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -2770,7 +2770,7 @@ components = [ "rust-bongo" ] .await .with_stderr(snapbox::str![[r#" ... -warn: Force-skipping unavailable component 'rust-bongo-[HOST_TRIPLE]' +warn: skipping unavailable component rust-bongo ... "#]]) .is_ok(); diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index a7691c8889..752e052545 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -2419,7 +2419,7 @@ error: component 'rls' for target '[HOST_TRIPLE]' is unavailable for download fo .await .with_stderr(snapbox::str![[r#" ... -warn: Force-skipping unavailable component 'rls-[HOST_TRIPLE]' +warn: skipping unavailable component rls ... "#]]) .is_ok(); @@ -2460,7 +2460,7 @@ async fn run_with_install_flag_against_unavailable_component() { .with_stderr(snapbox::str![[r#" info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) -warn: Force-skipping unavailable component 'rust-std-[HOST_TRIPLE]' +warn: skipping unavailable component rust-std info: downloading component[..] ... "#]]) From 011d9233d2330c93d8b4f27c89afa1c78e07950b Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:53:48 +0200 Subject: [PATCH 16/20] notifications: log directly when removing stray hash files --- src/dist/mod.rs | 6 ++++-- src/notifications.rs | 8 +------- tests/suite/cli_v2.rs | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/dist/mod.rs b/src/dist/mod.rs index 4acd5f7d5e..1d1998a59b 100644 --- a/src/dist/mod.rs +++ b/src/dist/mod.rs @@ -16,7 +16,6 @@ use tracing::{debug, info, warn}; use crate::{ config::{Cfg, dist_root_server}, errors::RustupError, - notifications::Notification, process::Process, toolchain::ToolchainName, utils, @@ -912,7 +911,10 @@ pub(crate) async fn update_from_dist( if let Some(hash) = opts.update_hash { // fresh_install means the toolchain isn't present, but hash_exists means there is a stray hash file if fresh_install && Path::exists(hash) { - (opts.dl_cfg.notify_handler)(Notification::StrayHash(hash)); + warn!( + "removing stray hash file in order to continue: {}", + hash.display() + ); std::fs::remove_file(hash)?; } } diff --git a/src/notifications.rs b/src/notifications.rs index e899fe1991..6362c8a6c6 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -14,7 +14,6 @@ pub(crate) enum Notification<'a> { CachedFileChecksumFailed, /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), - StrayHash(&'a Path), RetryingDownload(&'a str), DownloadingFile(&'a Url), /// Received the Content-Length of the to-be downloaded data with @@ -62,7 +61,7 @@ impl Notification<'_> { match self { FileAlreadyDownloaded => NotificationLevel::Debug, DownloadingComponent(_, _, _, _) | RetryingDownload(_) => NotificationLevel::Info, - CachedFileChecksumFailed | StrayHash(_) => NotificationLevel::Warn, + CachedFileChecksumFailed => NotificationLevel::Warn, SetDefaultBufferSize(_) => NotificationLevel::Trace, DownloadingFile(_) | DownloadContentLengthReceived(_, _) @@ -105,11 +104,6 @@ impl Display for Notification<'_> { write!(f, "downloading component '{}' for '{}'", c, t.unwrap()) } } - StrayHash(path) => write!( - f, - "removing stray hash found at '{}' in order to continue", - path.display() - ), RetryingDownload(url) => write!(f, "retrying download for '{url}'"), SetDefaultBufferSize(size) => write!( f, diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index 752e052545..4538ccdad9 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -1914,7 +1914,7 @@ async fn warn_about_and_remove_stray_hash() { .await .with_stderr(snapbox::str![[r#" ... -warn: removing stray hash found at '[..]/update-hashes/nightly-[HOST_TRIPLE]' in order to continue +warn: removing stray hash file in order to continue: [..]/update-hashes/nightly-[HOST_TRIPLE] ... "#]]) .is_ok(); From caf8be95f2ccc4c6a9194e05846c864eb8f77fd9 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:55:19 +0200 Subject: [PATCH 17/20] notifications: log directly when downloading files --- src/download/mod.rs | 3 +-- src/notifications.rs | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/download/mod.rs b/src/download/mod.rs index d777d2cb63..7deddf357a 100644 --- a/src/download/mod.rs +++ b/src/download/mod.rs @@ -102,8 +102,7 @@ async fn download_file_( use sha2::Digest; use std::cell::RefCell; - notify_handler(Notification::DownloadingFile(url)); - + debug!(url = %url, "downloading file"); let hasher = RefCell::new(hasher); // This callback will write the download to disk and optionally diff --git a/src/notifications.rs b/src/notifications.rs index 6362c8a6c6..1476a8b175 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -1,8 +1,6 @@ use std::fmt::{self, Display}; use std::path::{Path, PathBuf}; -use url::Url; - use crate::dist::TargetTriple; use crate::settings::MetadataVersion; use crate::utils::units; @@ -15,7 +13,6 @@ pub(crate) enum Notification<'a> { /// The URL of the download is passed as the last argument, to allow us to track concurrent downloads. DownloadingComponent(&'a str, &'a TargetTriple, Option<&'a TargetTriple>, &'a str), RetryingDownload(&'a str), - DownloadingFile(&'a Url), /// Received the Content-Length of the to-be downloaded data with /// the respective URL of the download (for tracking concurrent downloads). DownloadContentLengthReceived(u64, Option<&'a str>), @@ -63,8 +60,7 @@ impl Notification<'_> { DownloadingComponent(_, _, _, _) | RetryingDownload(_) => NotificationLevel::Info, CachedFileChecksumFailed => NotificationLevel::Warn, SetDefaultBufferSize(_) => NotificationLevel::Trace, - DownloadingFile(_) - | DownloadContentLengthReceived(_, _) + DownloadContentLengthReceived(_, _) | DownloadDataReceived(_, _) | DownloadFinished(_) | DownloadFailed(_) @@ -110,7 +106,6 @@ impl Display for Notification<'_> { "using up to {} of RAM to unpack components", units::Size::new(*size) ), - DownloadingFile(url) => write!(f, "downloading file from: '{url}'"), DownloadContentLengthReceived(len, _) => write!(f, "download size is: '{len}'"), DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), From 6ad046e8b9bf8330ae506e6d08fdee2208d5f962 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:56:54 +0200 Subject: [PATCH 18/20] notifications: log directly when resuming partial downloads --- src/download/mod.rs | 4 +--- src/notifications.rs | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/download/mod.rs b/src/download/mod.rs index 7deddf357a..8bdb470099 100644 --- a/src/download/mod.rs +++ b/src/download/mod.rs @@ -124,9 +124,7 @@ async fn download_file_( Event::DownloadDataReceived(data) => { notify_handler(Notification::DownloadDataReceived(data, Some(url.as_str()))); } - Event::ResumingPartialDownload => { - notify_handler(Notification::ResumingPartialDownload); - } + Event::ResumingPartialDownload => debug!("resuming partial download"), } Ok(()) diff --git a/src/notifications.rs b/src/notifications.rs index 1476a8b175..89d8201f85 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -22,7 +22,6 @@ pub(crate) enum Notification<'a> { DownloadFinished(Option<&'a str>), /// Download has failed. DownloadFailed(&'a str), - ResumingPartialDownload, /// This would make more sense as a crate::notifications::Notification /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. @@ -63,8 +62,7 @@ impl Notification<'_> { DownloadContentLengthReceived(_, _) | DownloadDataReceived(_, _) | DownloadFinished(_) - | DownloadFailed(_) - | ResumingPartialDownload => NotificationLevel::Debug, + | DownloadFailed(_) => NotificationLevel::Debug, ToolchainDirectory(_) | LookingForToolchain(_) | InstallingToolchain(_) @@ -110,7 +108,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - ResumingPartialDownload => write!(f, "resuming partial download"), SetAutoInstall(auto) => write!(f, "auto install set to '{auto}'"), SetDefaultToolchain(None) => write!(f, "default toolchain unset"), SetDefaultToolchain(Some(name)) => write!(f, "default toolchain set to '{name}'"), From 9826ece083604f8f61d5c4db42d7f97963897caf Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 10:59:45 +0200 Subject: [PATCH 19/20] notifications: log directly when setting auto install mode --- src/config.rs | 4 ++-- src/notifications.rs | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/config.rs b/src/config.rs index fb75b6a9ae..ea7f9a8141 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,7 @@ use anyhow::{Context, Result, anyhow, bail}; use serde::Deserialize; use thiserror::Error as ThisError; use tokio_stream::StreamExt; -use tracing::{error, trace}; +use tracing::{error, info, trace}; use crate::dist::AutoInstallMode; use crate::{ @@ -376,7 +376,7 @@ impl<'a> Cfg<'a> { s.auto_install = Some(mode); Ok(()) })?; - (self.notify_handler)(Notification::SetAutoInstall(mode.as_str())); + info!("setting auto install mode to {}", mode.as_str()); Ok(()) } diff --git a/src/notifications.rs b/src/notifications.rs index 89d8201f85..9fd2243935 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - SetAutoInstall(&'a str), SetDefaultToolchain(Option<&'a ToolchainName>), SetOverrideToolchain(&'a Path, &'a str), SetProfile(&'a str), @@ -70,8 +69,7 @@ impl Notification<'_> { | ReadMetadataVersion(_) | InstalledToolchain(_) | UpdateHashMatches => NotificationLevel::Debug, - SetAutoInstall(_) - | SetDefaultToolchain(_) + SetDefaultToolchain(_) | SetOverrideToolchain(_, _) | SetProfile(_) | SetSelfUpdate(_) @@ -108,7 +106,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - SetAutoInstall(auto) => write!(f, "auto install set to '{auto}'"), SetDefaultToolchain(None) => write!(f, "default toolchain unset"), SetDefaultToolchain(Some(name)) => write!(f, "default toolchain set to '{name}'"), SetOverrideToolchain(path, name) => write!( From 054e3c6c8e3395931742f4550e836bae0d03a6b5 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 24 Sep 2025 11:01:26 +0200 Subject: [PATCH 20/20] notifications: log directly when setting the default toolchain --- src/config.rs | 7 ++++++- src/notifications.rs | 6 +----- tests/suite/cli_exact.rs | 4 ++-- tests/suite/cli_rustup.rs | 6 +++--- tests/suite/cli_self_upd.rs | 8 ++++---- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/config.rs b/src/config.rs index ea7f9a8141..b4c574fdc7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -344,7 +344,12 @@ impl<'a> Cfg<'a> { s.default_toolchain = toolchain.map(|t| t.to_string()); Ok(()) })?; - (self.notify_handler)(Notification::SetDefaultToolchain(toolchain)); + + match toolchain { + Some(t) => info!("default toolchain set to {t}"), + None => info!("default toolchain unset"), + } + Ok(()) } diff --git a/src/notifications.rs b/src/notifications.rs index 9fd2243935..903c19a142 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - SetDefaultToolchain(Option<&'a ToolchainName>), SetOverrideToolchain(&'a Path, &'a str), SetProfile(&'a str), SetSelfUpdate(&'a str), @@ -69,8 +68,7 @@ impl Notification<'_> { | ReadMetadataVersion(_) | InstalledToolchain(_) | UpdateHashMatches => NotificationLevel::Debug, - SetDefaultToolchain(_) - | SetOverrideToolchain(_, _) + SetOverrideToolchain(_, _) | SetProfile(_) | SetSelfUpdate(_) | UsingExistingToolchain(_) @@ -106,8 +104,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - SetDefaultToolchain(None) => write!(f, "default toolchain unset"), - SetDefaultToolchain(Some(name)) => write!(f, "default toolchain set to '{name}'"), SetOverrideToolchain(path, name) => write!( f, "override toolchain for '{}' set to '{}'", diff --git a/tests/suite/cli_exact.rs b/tests/suite/cli_exact.rs index d993da11fb..f9af3c16a3 100644 --- a/tests/suite/cli_exact.rs +++ b/tests/suite/cli_exact.rs @@ -24,7 +24,7 @@ info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... -info: default toolchain set to 'nightly-[HOST_TRIPLE]' +info: default toolchain set to nightly-[HOST_TRIPLE] "#]]); cx.config @@ -325,7 +325,7 @@ info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... -info: default toolchain set to 'nightly-[HOST_TRIPLE]' +info: default toolchain set to nightly-[HOST_TRIPLE] "#]]); cx.config diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index 23765d0405..7b1b0787dc 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -286,7 +286,7 @@ info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... -info: default toolchain set to 'nightly-[HOST_TRIPLE]' +info: default toolchain set to nightly-[HOST_TRIPLE] "#]]) .is_ok(); @@ -323,7 +323,7 @@ async fn default_override() { .await .with_stderr(snapbox::str![[r#" info: using existing install for 'stable-[HOST_TRIPLE]' -info: default toolchain set to 'stable-[HOST_TRIPLE]' +info: default toolchain set to stable-[HOST_TRIPLE] info: note that the toolchain 'nightly-[HOST_TRIPLE]' is currently in use (directory override for '[..]') "#]]) @@ -3721,7 +3721,7 @@ info: syncing channel updates for nightly-[HOST_TRIPLE] info: latest update on 2015-01-02 for version 1.3.0 (hash-nightly-2) info: downloading component[..] ... -info: default toolchain set to 'nightly-[HOST_TRIPLE]' +info: default toolchain set to nightly-[HOST_TRIPLE] "#]]) .is_ok(); diff --git a/tests/suite/cli_self_upd.rs b/tests/suite/cli_self_upd.rs index 006d52e61e..54818d8f64 100644 --- a/tests/suite/cli_self_upd.rs +++ b/tests/suite/cli_self_upd.rs @@ -74,7 +74,7 @@ info: syncing channel updates for stable-[HOST_TRIPLE] info: latest update on 2015-01-02 for version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... -info: default toolchain set to 'stable-[HOST_TRIPLE]' +info: default toolchain set to stable-[HOST_TRIPLE] "#]]) .is_ok(); @@ -119,8 +119,8 @@ info: syncing channel updates for stable-[HOST_TRIPLE] info: latest update on 2015-01-02 for version 1.1.0 (hash-stable-1.1.0) info: downloading component[..] ... -info: default toolchain set to 'stable-[HOST_TRIPLE]' - +info: default toolchain set to stable-[HOST_TRIPLE] +... "#]]) .is_ok(); @@ -899,7 +899,7 @@ async fn reinstall_specifying_different_toolchain() { .await .with_stderr(snapbox::str![[r#" ... -info: default toolchain set to 'nightly-[HOST_TRIPLE]' +info: default toolchain set to nightly-[HOST_TRIPLE] ... "#]]) .is_ok();