diff --git a/compiler-core/src/error.rs b/compiler-core/src/error.rs index 4ebc1f71d35..cd863d78f06 100644 --- a/compiler-core/src/error.rs +++ b/compiler-core/src/error.rs @@ -1032,20 +1032,55 @@ https://gleam.run/getting-started/installing/", Documentation for installing rebar3 can be viewed here: https://gleam.run/getting-started/installing/", ), - _ => (), - } - match (program.as_str(), env::consts::OS) { - // TODO: Further suggestions for other OSes? - ("erl" | "erlc" | "escript", "macos") => text.push_str( - " -You can also install Erlang via homebrew using \"brew install erlang\"", - ), - ("rebar3", "macos") => text.push_str( + "bun" => text.push_str( " -You can also install rebar3 via homebrew using \"brew install rebar3\"", +Documentation for installing bun can be viewed here: +https://bun.sh/docs/installation/ +You may need to restart your shell after installing bun.", ), _ => (), - }; + } + match env::consts::OS { + "macos" => { + fn brew_install(program: &str) -> String { + format!("\nYou can install {} via homebrew: \"brew install {}\"", program, program) + } + match program.as_str() { + "erl" | "erlc" | "escript" => text.push_str(&brew_install("erlang")), + "rebar3" => text.push_str(&brew_install("rebar3")), + "deno" => text.push_str(&brew_install("deno")), + "elixir" => text.push_str(&brew_install("elixir")), + other => text.push_str(&format!( + "\nYou might need to install {} manually.", + other + )), + } + } + "linux" => { + if let Ok(distro) = std::fs::read_to_string("/etc/os-release") { + if distro.contains("ubuntu") || distro.contains("debian") { + text.push_str(&format!( + "\nYou can try installing {} using apt: \"sudo apt install {}\".", + program, program + )); + } else if distro.contains("fedora") || distro.contains("centos") { + text.push_str(&format!( + "\nYou can try installing {} using dnf: \"sudo dnf install {}\".", + program, program + )); + } + } else { + text.push_str(&format!( + "\nYou might need to install {} manually.", + program + )); + } + } + _ => text.push_str(&format!( + "\nYou might need to install {} manually.", + program + )), + } vec![Diagnostic { title: "Program not found".into(),