diff --git a/Cargo.lock b/Cargo.lock index e2241b647309f4..fb56e9b0a46bc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -608,15 +608,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "directories" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs" version = "4.0.0" @@ -2007,7 +1998,6 @@ dependencies = [ "similar", "strum", "textwrap", - "update-informer", "ureq", "walkdir", ] @@ -2758,19 +2748,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" -[[package]] -name = "update-informer" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "152ff185ca29f7f487c51ca785b0f1d85970c4581f4cdd12ed499227890200f5" -dependencies = [ - "directories", - "semver", - "serde", - "serde_json", - "ureq", -] - [[package]] name = "ureq" version = "2.6.2" @@ -2782,8 +2759,6 @@ dependencies = [ "log", "once_cell", "rustls", - "serde", - "serde_json", "url", "webpki", "webpki-roots", diff --git a/ruff_cli/Cargo.toml b/ruff_cli/Cargo.toml index dddccdaa5cce0d..fdfe62eaae0de9 100644 --- a/ruff_cli/Cargo.toml +++ b/ruff_cli/Cargo.toml @@ -51,7 +51,6 @@ serde = { version = "1.0.147", features = ["derive"] } serde_json = { version = "1.0.87" } similar = { version = "2.2.1" } textwrap = { version = "0.16.0" } -update-informer = { version = "0.6.0", default-features = false, features = ["pypi"], optional = true } walkdir = { version = "2.3.2" } strum = "0.24.1" @@ -60,10 +59,6 @@ assert_cmd = { version = "2.0.4" } strum = { version = "0.24.1" } ureq = { version = "2.5.0", features = [] } -[features] -default = ["update-informer"] -update-informer = ["dep:update-informer"] - [package.metadata.maturin] name = "ruff" # Setting the name here is necessary for maturin to include the package in its builds. diff --git a/ruff_cli/src/args.rs b/ruff_cli/src/args.rs index 2b6c98f7b1b1e0..278321e86e4de6 100644 --- a/ruff_cli/src/args.rs +++ b/ruff_cli/src/args.rs @@ -209,7 +209,7 @@ pub struct CheckArgs { /// Exit with status code "0", even upon detecting lint violations. #[arg(short, long, help_heading = "Miscellaneous")] pub exit_zero: bool, - /// Enable or disable automatic update checks. + /// (Deprecated, does nothing.) Enable or disable automatic update checks. #[arg( long, overrides_with("no_update_check"), diff --git a/ruff_cli/src/main.rs b/ruff_cli/src/main.rs index 96877f7933e80e..50e3f8957d3c47 100644 --- a/ruff_cli/src/main.rs +++ b/ruff_cli/src/main.rs @@ -31,8 +31,6 @@ mod diagnostics; mod iterators; mod printer; mod resolve; -#[cfg(all(feature = "update-informer"))] -pub mod updates; fn inner_main() -> Result { let mut args: Vec<_> = std::env::args_os().collect(); @@ -258,14 +256,10 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result { } } - // Check for updates if we're in a non-silent log level. - #[cfg(feature = "update-informer")] - if update_check - && !is_stdin - && log_level >= LogLevel::Default - && atty::is(atty::Stream::Stdout) - { - drop(updates::check_for_updates()); + if update_check { + warn_user_once!( + "update-check has been removed; setting it will be an error in a future version." + ); } if !cli.exit_zero { diff --git a/ruff_cli/src/updates.rs b/ruff_cli/src/updates.rs deleted file mode 100644 index 41fa51f46e3b26..00000000000000 --- a/ruff_cli/src/updates.rs +++ /dev/null @@ -1,75 +0,0 @@ -use std::fs::{create_dir_all, read_to_string, File}; -use std::io::Write; -use std::path::{Path, PathBuf}; - -use anyhow::Result; -use colored::Colorize; - -const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME"); -const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); - -fn cache_dir() -> &'static str { - "./.ruff_cache" -} - -fn file_path() -> PathBuf { - Path::new(cache_dir()).join(".update-informer") -} - -/// Get the "latest" version for which the user has been informed. -fn get_latest() -> Result> { - let path = file_path(); - if path.exists() { - Ok(Some(read_to_string(path)?.trim().to_string())) - } else { - Ok(None) - } -} - -/// Set the "latest" version for which the user has been informed. -fn set_latest(version: &str) -> Result<()> { - create_dir_all(cache_dir())?; - let path = file_path(); - let mut file = File::create(path)?; - file.write_all(version.trim().as_bytes())?; - Ok(()) -} - -/// Update the user if a newer version is available. -pub fn check_for_updates() -> Result<()> { - use update_informer::{registry, Check}; - - let informer = update_informer::new(registry::PyPI, CARGO_PKG_NAME, CARGO_PKG_VERSION); - - if let Some(new_version) = informer - .check_version() - .ok() - .flatten() - .map(|version| version.to_string()) - { - // If we've already notified the user about this version, return early. - if let Some(latest_version) = get_latest()? { - if latest_version == new_version { - return Ok(()); - } - } - set_latest(&new_version)?; - - let msg = format!( - "A new version of {pkg_name} is available: v{pkg_version} -> {new_version}", - pkg_name = CARGO_PKG_NAME.italic().cyan(), - pkg_version = CARGO_PKG_VERSION, - new_version = new_version.green() - ); - - let cmd = format!( - "Run to update: {cmd} {pkg_name}", - cmd = "pip3 install --upgrade".green(), - pkg_name = CARGO_PKG_NAME.green() - ); - - println!("\n{msg}\n{cmd}"); - } - - Ok(()) -}