From e7c5b38695887361f350bb12607ebe576ac4f1d6 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:24:35 -0300 Subject: [PATCH 1/4] Error when attempting to launch invalid julia binary. --- src/bin/julialauncher.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index 01975de7..776dec46 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -5,6 +5,7 @@ use itertools::Itertools; use juliaup::config_file::{load_config_db, JuliaupConfig, JuliaupConfigChannel}; use juliaup::global_paths::get_paths; use juliaup::jsonstructs_versionsdb::JuliaupVersionDB; +use juliaup::utils::is_valid_julia_path; use juliaup::versions_file::load_versions_db; #[cfg(not(windows))] use nix::{ @@ -396,9 +397,16 @@ fn run_app() -> Result { } // replace the current process - std::process::Command::new(julia_path) - .args(&new_args) - .exec(); + if is_valid_julia_path(&julia_path) { + std::process::Command::new(julia_path) + .args(&new_args) + .exec(); + } else { + panic!( + "Could not launch Julia. Verify that there is a valid Julia binary at \"{}\".", + julia_path.to_string_lossy() + ); + } // this is never reached Ok(0) From ace3398743f7d38edd8d5161bccad6ce6568d71f Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:40:59 -0300 Subject: [PATCH 2/4] Warn when linking to invalid julia binary --- src/command_link.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/command_link.rs b/src/command_link.rs index c7fcb2e4..cf840c8f 100644 --- a/src/command_link.rs +++ b/src/command_link.rs @@ -3,6 +3,7 @@ use crate::config_file::{load_mut_config_db, save_config_db}; use crate::global_paths::GlobalPaths; #[cfg(not(windows))] use crate::operations::create_symlink; +use crate::utils::is_valid_julia_path; use crate::versions_file::load_versions_db; use anyhow::{bail, Context, Result}; use path_absolutize::Absolutize; @@ -32,6 +33,10 @@ pub fn run_command_link( .absolutize() .with_context(|| format!("Failed to convert path `{}` to absolute path.", file))?; + if !is_valid_julia_path(&absolute_file_path.to_path_buf()) { + eprintln!("WARNING: There is no julia binary at {}. If this was a mistake, run `juliaup remove {}` and try again.", absolute_file_path.to_string_lossy(), channel); + } + config_file.data.installed_channels.insert( channel.to_string(), JuliaupConfigChannel::LinkedChannel { From abe98f77ea04f8b62f9dfdeac0f1f0d2c308ab56 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:31:24 -0300 Subject: [PATCH 3/4] Fix windows check --- src/bin/julialauncher.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index 776dec46..759f7b57 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -5,6 +5,7 @@ use itertools::Itertools; use juliaup::config_file::{load_config_db, JuliaupConfig, JuliaupConfigChannel}; use juliaup::global_paths::get_paths; use juliaup::jsonstructs_versionsdb::JuliaupVersionDB; +#[cfg(not(windows))] use juliaup::utils::is_valid_julia_path; use juliaup::versions_file::load_versions_db; #[cfg(not(windows))] From e9fe7e3313189fa39ac7b897511c9bf967e3be57 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Fri, 6 Sep 2024 18:55:36 -0300 Subject: [PATCH 4/4] Address comment --- src/bin/julialauncher.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index 759f7b57..6a63b8c5 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -5,8 +5,6 @@ use itertools::Itertools; use juliaup::config_file::{load_config_db, JuliaupConfig, JuliaupConfigChannel}; use juliaup::global_paths::get_paths; use juliaup::jsonstructs_versionsdb::JuliaupVersionDB; -#[cfg(not(windows))] -use juliaup::utils::is_valid_julia_path; use juliaup::versions_file::load_versions_db; #[cfg(not(windows))] use nix::{ @@ -398,19 +396,15 @@ fn run_app() -> Result { } // replace the current process - if is_valid_julia_path(&julia_path) { - std::process::Command::new(julia_path) - .args(&new_args) - .exec(); - } else { - panic!( - "Could not launch Julia. Verify that there is a valid Julia binary at \"{}\".", - julia_path.to_string_lossy() - ); - } - - // this is never reached - Ok(0) + std::process::Command::new(&julia_path) + .args(&new_args) + .exec(); + + // this is only ever reached if launching Julia fails + panic!( + "Could not launch Julia. Verify that there is a valid Julia binary at \"{}\".", + julia_path.to_string_lossy() + ) } Ok(ForkResult::Child) => { // double-fork to prevent zombies