From 3f6d4ffc7e21260a2757443e132671045fc66c8c Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 14:17:58 -0700 Subject: [PATCH 01/12] Clean up error messages in the launcher --- src/bin/julialauncher.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index 5cfc8d2a..a9fde56e 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -1,5 +1,5 @@ use anyhow::{anyhow, Context, Result}; -use console::Term; +use console::{style, Term}; use is_terminal::IsTerminal; use itertools::Itertools; use juliaup::config_file::{load_config_db, JuliaupConfig, JuliaupConfigChannel}; @@ -140,8 +140,7 @@ fn check_channel_uptodate( let latest_version = &versions_db .available_channels .get(channel) - .ok_or_else(|| { - anyhow!( + .ok_or_else(|| UserError {msg: format!( "The channel `{}` does not exist in the versions database.", channel ) @@ -184,24 +183,24 @@ fn get_julia_path_from_channel( if channel_valid { UserError { msg: format!("`{}` is not installed. Please run `juliaup add {}` to install channel or version.", channel, channel) } } else { - UserError { msg: format!("ERROR: Invalid Juliaup channel `{}`. Please run `juliaup list` to get a list of valid channels and versions.", channel) } + UserError { msg: format!("Invalid Juliaup channel `{}`. Please run `juliaup list` to get a list of valid channels and versions.", channel) } } }.into(), JuliaupChannelSource::EnvVar=> { if channel_valid { UserError { msg: format!("`{}` from environment variable JULIAUP_CHANNEL is not installed. Please run `juliaup add {}` to install channel or version.", channel, channel) } } else { - UserError { msg: format!("ERROR: Invalid Juliaup channel `{}` from environment variable JULIAUP_CHANNEL. Please run `juliaup list` to get a list of valid channels and versions.", channel) } + UserError { msg: format!("Invalid Juliaup channel `{}` from environment variable JULIAUP_CHANNEL. Please run `juliaup list` to get a list of valid channels and versions.", channel) } } }.into(), JuliaupChannelSource::Override=> { if channel_valid { UserError { msg: format!("`{}` from directory override is not installed. Please run `juliaup add {}` to install channel or version.", channel, channel) } } else { - UserError { msg: format!("ERROR: Invalid Juliaup channel `{}` from directory override. Please run `juliaup list` to get a list of valid channels and versions.", channel) } + UserError { msg: format!("Invalid Juliaup channel `{}` from directory override. Please run `juliaup list` to get a list of valid channels and versions.", channel) } } }.into(), - JuliaupChannelSource::Default => anyhow!("The Juliaup configuration is in an inconsistent state, the currently configured default channel `{}` is not installed.", channel) + JuliaupChannelSource::Default => UserError {msg: format!("The Juliaup configuration is in an inconsistent state, the currently configured default channel `{}` is not installed.", channel) } })?; match channel_info { @@ -527,7 +526,10 @@ fn main() -> Result { if let Err(err) = &client_status { if let Some(e) = err.downcast_ref::() { - eprintln!("{}", e.msg); + eprintln!("{} {}", + style("ERROR:").red().bold(), + e.msg + ); return Ok(std::process::ExitCode::FAILURE); } else { From cb889d35f3703345b90c44928f1dd5fb3f1ba46f Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 14:25:51 -0700 Subject: [PATCH 02/12] Update src/bin/julialauncher.rs Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/bin/julialauncher.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index a9fde56e..f23532fd 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -140,7 +140,8 @@ fn check_channel_uptodate( let latest_version = &versions_db .available_channels .get(channel) - .ok_or_else(|| UserError {msg: format!( + .ok_or_else(|| UserError { + msg: format!( "The channel `{}` does not exist in the versions database.", channel ) From 734d0ec5051d07a30f89620ad0f6249aad3c6c6e Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 14:25:57 -0700 Subject: [PATCH 03/12] Update src/bin/julialauncher.rs Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/bin/julialauncher.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index f23532fd..a26702ee 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -144,7 +144,7 @@ fn check_channel_uptodate( msg: format!( "The channel `{}` does not exist in the versions database.", channel - ) + ), })? .version; From 1edead1e0a256d0793ff6cc0fc991fdf24a4bfe2 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 14:26:04 -0700 Subject: [PATCH 04/12] Update src/bin/julialauncher.rs Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/bin/julialauncher.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index a26702ee..2abd45d8 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -527,10 +527,7 @@ fn main() -> Result { if let Err(err) = &client_status { if let Some(e) = err.downcast_ref::() { - eprintln!("{} {}", - style("ERROR:").red().bold(), - e.msg - ); + eprintln!("{} {}", style("ERROR:").red().bold(), e.msg); return Ok(std::process::ExitCode::FAILURE); } else { From 0804e3a11241073dfea1309cd03165e48eaf93db Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 16:02:33 -0700 Subject: [PATCH 05/12] Fix tests --- tests/channel_selection.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/channel_selection.rs b/tests/channel_selection.rs index 3ea5bac3..2bda28b7 100644 --- a/tests/channel_selection.rs +++ b/tests/channel_selection.rs @@ -137,7 +137,7 @@ fn channel_selection() { .env("JULIAUP_CHANNEL", "1.7.4") .assert() .failure() - .stderr("`1.8.2` is not installed. Please run `juliaup add 1.8.2` to install channel or version.\n"); + .stderr("ERROR: `1.8.2` is not installed. Please run `juliaup add 1.8.2` to install channel or version.\n"); // https://github.com/JuliaLang/juliaup/issues/820 Command::cargo_bin("julia") @@ -150,5 +150,5 @@ fn channel_selection() { .env("JULIAUP_CHANNEL", "1.7.4") .assert() .failure() - .stderr("`nightly` is not installed. Please run `juliaup add nightly` to install channel or version.\n"); + .stderr("ERROR: `nightly` is not installed. Please run `juliaup add nightly` to install channel or version.\n"); } From 2c5eaf9f45fe3be8785250b8548923dbea06a72c Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 17:19:03 -0700 Subject: [PATCH 06/12] Fix tests --- tests/command_initial_setup_from_launcher_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/command_initial_setup_from_launcher_test.rs b/tests/command_initial_setup_from_launcher_test.rs index bb5d348f..edd1bb85 100644 --- a/tests/command_initial_setup_from_launcher_test.rs +++ b/tests/command_initial_setup_from_launcher_test.rs @@ -18,7 +18,7 @@ fn command_initial_setup() { .env("JULIAUP_DEPOT_PATH", depot_dir.path()) .assert() .success() - .stdout(""); + .stdout(predicate::str::is_empty().or(predicate::str::starts_with("Checking standard library notarization").and(predicate::str::ends_with("done.")))); depot_dir .child(Path::new("juliaup").join("juliaup.json")) From 048b95eb0db97768eaa3b8d3e5cdab0166d63696 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 17:20:21 -0700 Subject: [PATCH 07/12] Update tests/command_initial_setup_from_launcher_test.rs Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- tests/command_initial_setup_from_launcher_test.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/command_initial_setup_from_launcher_test.rs b/tests/command_initial_setup_from_launcher_test.rs index edd1bb85..628d80d5 100644 --- a/tests/command_initial_setup_from_launcher_test.rs +++ b/tests/command_initial_setup_from_launcher_test.rs @@ -18,7 +18,12 @@ fn command_initial_setup() { .env("JULIAUP_DEPOT_PATH", depot_dir.path()) .assert() .success() - .stdout(predicate::str::is_empty().or(predicate::str::starts_with("Checking standard library notarization").and(predicate::str::ends_with("done.")))); + .stdout( + predicate::str::is_empty().or(predicate::str::starts_with( + "Checking standard library notarization", + ) + .and(predicate::str::ends_with("done."))), + ); depot_dir .child(Path::new("juliaup").join("juliaup.json")) From 960ae83160695c94a95d7cee22bbb5da5a8eff24 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 17:36:24 -0700 Subject: [PATCH 08/12] Print more things to stderr rather than stdout --- src/bin/juliaup.rs | 2 +- src/command_selfupdate.rs | 4 ++-- src/operations.rs | 8 ++++---- tests/command_initial_setup_from_launcher_test.rs | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bin/juliaup.rs b/src/bin/juliaup.rs index d2a2e579..33835acf 100644 --- a/src/bin/juliaup.rs +++ b/src/bin/juliaup.rs @@ -78,7 +78,7 @@ fn main() -> Result<()> { .unwrap(); if !depl_result.IsRegistered().unwrap() { - println!( + eprintln!( "Failed to register package identity. Error Message ${:?}", depl_result.ErrorText() ); diff --git a/src/command_selfupdate.rs b/src/command_selfupdate.rs index 659987ff..dc5de6f7 100644 --- a/src/command_selfupdate.rs +++ b/src/command_selfupdate.rs @@ -127,7 +127,7 @@ pub fn run_command_selfupdate(paths: &GlobalPaths) -> Result<()> { .with_context(|| "Call to Size on update results failed.")? > 0 { - println!("An update is available."); + eprintln!("An update is available."); let download_operation = update_manager .RequestDownloadAndInstallStorePackageUpdatesAsync(&updates) @@ -138,7 +138,7 @@ pub fn run_command_selfupdate(paths: &GlobalPaths) -> Result<()> { })?; // This code will not be reached if the user opts to install updates } else { - println!("No updates available."); + eprintln!("No updates available."); } Ok(()) diff --git a/src/operations.rs b/src/operations.rs index abff33cc..2879cea9 100644 --- a/src/operations.rs +++ b/src/operations.rs @@ -405,14 +405,14 @@ pub fn install_version( ) })?; - print!("Checking standard library notarization"); + eprint!("Checking standard library notarization"); let _ = std::io::stdout().flush(); let exit_status = std::process::Command::new(&julia_path) .env("JULIA_LOAD_PATH", "@stdlib") .arg("--startup-file=no") .arg("-e") - .arg("foreach(p -> begin print('.'); @eval(import $(Symbol(p))) end, filter!(x -> isfile(joinpath(Sys.STDLIB, x, \"src\", \"$(x).jl\")), readdir(Sys.STDLIB)))") + .arg("foreach(p -> begin print(stderr, '.'); @eval(import $(Symbol(p))) end, filter!(x -> isfile(joinpath(Sys.STDLIB, x, \"src\", \"$(x).jl\")), readdir(Sys.STDLIB)))") // .stdout(std::process::Stdio::null()) // .stderr(std::process::Stdio::null()) // .stdin(std::process::Stdio::null()) @@ -420,9 +420,9 @@ pub fn install_version( .unwrap(); if exit_status.success() { - println!("done.") + eprintln!("done.") } else { - println!("failed with {}.", exit_status); + eprintln!("failed with {}.", exit_status); } } diff --git a/tests/command_initial_setup_from_launcher_test.rs b/tests/command_initial_setup_from_launcher_test.rs index edd1bb85..06265f95 100644 --- a/tests/command_initial_setup_from_launcher_test.rs +++ b/tests/command_initial_setup_from_launcher_test.rs @@ -18,7 +18,8 @@ fn command_initial_setup() { .env("JULIAUP_DEPOT_PATH", depot_dir.path()) .assert() .success() - .stdout(predicate::str::is_empty().or(predicate::str::starts_with("Checking standard library notarization").and(predicate::str::ends_with("done.")))); + .stdout(predicate::str::is_empty()) + .stderr(predicate::str::is_empty().or(predicate::str::starts_with("Checking standard library notarization").and(predicate::str::ends_with("done.")))); depot_dir .child(Path::new("juliaup").join("juliaup.json")) From 581b60849c32396adbe84ffe22f3c02568dcaa81 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 17:45:04 -0700 Subject: [PATCH 09/12] Fix tests --- tests/command_initial_setup_from_launcher_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/command_initial_setup_from_launcher_test.rs b/tests/command_initial_setup_from_launcher_test.rs index 06265f95..bc949a7b 100644 --- a/tests/command_initial_setup_from_launcher_test.rs +++ b/tests/command_initial_setup_from_launcher_test.rs @@ -19,7 +19,7 @@ fn command_initial_setup() { .assert() .success() .stdout(predicate::str::is_empty()) - .stderr(predicate::str::is_empty().or(predicate::str::starts_with("Checking standard library notarization").and(predicate::str::ends_with("done.")))); + .stderr(predicate::eq("Installing Julia 1.11.0+0.x64.linux.gnu\n").or(predicate::str::starts_with("Installing Julia 1.11.0+0.x64.linux.gnu\nChecking standard library notarization").and(predicate::str::ends_with("done.")))); depot_dir .child(Path::new("juliaup").join("juliaup.json")) From 93669943fb94e1408eacf0b4d1d55540398080af Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 18:03:53 -0700 Subject: [PATCH 10/12] Fix tests --- tests/command_initial_setup_from_launcher_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/command_initial_setup_from_launcher_test.rs b/tests/command_initial_setup_from_launcher_test.rs index bc949a7b..a93587fd 100644 --- a/tests/command_initial_setup_from_launcher_test.rs +++ b/tests/command_initial_setup_from_launcher_test.rs @@ -19,7 +19,7 @@ fn command_initial_setup() { .assert() .success() .stdout(predicate::str::is_empty()) - .stderr(predicate::eq("Installing Julia 1.11.0+0.x64.linux.gnu\n").or(predicate::str::starts_with("Installing Julia 1.11.0+0.x64.linux.gnu\nChecking standard library notarization").and(predicate::str::ends_with("done.")))); + .stderr(predicate::str::starts_with("Installing Julia 1.11.0").and(predicate::str::contains("apple.darwin14").not().or(predicate::str::contains("Checking standard library notarization").and(predicate::str::ends_with("done."))))); depot_dir .child(Path::new("juliaup").join("juliaup.json")) From 52cb1e8b249963c08c69ef9cc3627efe14c9d63f Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 18:20:52 -0700 Subject: [PATCH 11/12] Fix tests --- tests/command_initial_setup_from_launcher_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/command_initial_setup_from_launcher_test.rs b/tests/command_initial_setup_from_launcher_test.rs index a93587fd..bbc13ffe 100644 --- a/tests/command_initial_setup_from_launcher_test.rs +++ b/tests/command_initial_setup_from_launcher_test.rs @@ -19,7 +19,7 @@ fn command_initial_setup() { .assert() .success() .stdout(predicate::str::is_empty()) - .stderr(predicate::str::starts_with("Installing Julia 1.11.0").and(predicate::str::contains("apple.darwin14").not().or(predicate::str::contains("Checking standard library notarization").and(predicate::str::ends_with("done."))))); + .stderr(predicate::str::starts_with("Installing Julia 1.11.0").and(predicate::str::contains("apple.darwin14").not().or(predicate::str::contains("Checking standard library notarization").and(predicate::str::ends_with("done.\n"))))); depot_dir .child(Path::new("juliaup").join("juliaup.json")) From 4d92a230bb6555e3f977d8d02e76c0c45d8e00f1 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Fri, 11 Oct 2024 23:22:43 -0700 Subject: [PATCH 12/12] Update tests/command_initial_setup_from_launcher_test.rs Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- tests/command_initial_setup_from_launcher_test.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/command_initial_setup_from_launcher_test.rs b/tests/command_initial_setup_from_launcher_test.rs index bbc13ffe..47ac9eba 100644 --- a/tests/command_initial_setup_from_launcher_test.rs +++ b/tests/command_initial_setup_from_launcher_test.rs @@ -19,7 +19,16 @@ fn command_initial_setup() { .assert() .success() .stdout(predicate::str::is_empty()) - .stderr(predicate::str::starts_with("Installing Julia 1.11.0").and(predicate::str::contains("apple.darwin14").not().or(predicate::str::contains("Checking standard library notarization").and(predicate::str::ends_with("done.\n"))))); + .stderr( + predicate::str::starts_with("Installing Julia 1.11.0").and( + predicate::str::contains("apple.darwin14") + .not() + .or( + predicate::str::contains("Checking standard library notarization") + .and(predicate::str::ends_with("done.\n")), + ), + ), + ); depot_dir .child(Path::new("juliaup").join("juliaup.json"))