From 988ef95591ec9893a7691f8aad41f3c37a758088 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Mon, 21 Mar 2022 11:35:35 -0700 Subject: [PATCH] Handle Rosetta not installed case on MacOS M1 --- src/bin/juliainstaller.rs | 18 ++++++++++++++++++ src/command_add.rs | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/bin/juliainstaller.rs b/src/bin/juliainstaller.rs index a7b8a919..33ebc7eb 100644 --- a/src/bin/juliainstaller.rs +++ b/src/bin/juliainstaller.rs @@ -188,6 +188,24 @@ pub fn main() -> Result<()> { println!("{}", style("Welcome to Julia!").bold()); println!(""); + #[cfg(all(target_os="macos", target_arch="aarch64"))] + { + match std::process::Command::new("arch") + .args(["-x86_64", "/bin/bash", "-c", "arch"]) + .output() { + Ok(value) => { + if String::from_utf8(value.stdout)? != "i386" { + println!("It seems that you have not yet installed Rosetta, please install it with `softwareupdate --install-rosetta` before you try to install Julia."); + return Ok(()) + } + }, + Err(_err) => { + println!("It seems that you have not yet installed Rosetta, please install it with `softwareupdate --install-rosetta` before you try to install Julia."); + return Ok(()) + } + } + } + if is_juliaup_installed() { println!("It seems that Juliaup is already installed on this system. Please remove the previous installation of Juliaup before you try to install a new version."); diff --git a/src/command_add.rs b/src/command_add.rs index 0d856e67..83109177 100644 --- a/src/command_add.rs +++ b/src/command_add.rs @@ -23,6 +23,29 @@ pub fn run_command_add(channel: String, paths: &GlobalPaths) -> Result<()> { if config_file.data.installed_channels.contains_key(&channel) { bail!("'{}' is already installed.", &channel); } + + #[cfg(all(target_os="macos", target_arch="aarch64"))] + { + use crate::utils::parse_versionstring; + + let (platform, _) = parse_versionstring(&required_version)?; + + if platform=="x64" { + match std::process::Command::new("arch") + .args(["-x86_64", "/bin/bash", "-c", "arch"]) + .output() { + Ok(value) => { + if String::from_utf8(value.stdout)? != "i386" { + bail!("It seems that you have not yet installed Rosetta, please install it with `softwareupdate --install-rosetta` before you try to install Julia."); + } + () + }, + Err(_err) => { + bail!("It seems that you have not yet installed Rosetta, please install it with `softwareupdate --install-rosetta` before you try to install Julia."); + } + } + } + } install_version(&required_version, &mut config_file.data, &version_db, paths)?;