Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Rosetta not installed case on MacOS M1 #272

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/bin/juliainstaller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary, though? I think a comment explaining that (or even a message to the user doing so) would be helpful.

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.");

Expand Down
23 changes: 23 additions & 0 deletions src/command_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Expand Down