Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions e2e/core/test_erlang_precompiled_strict
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

cat <<'EOF' >mise.toml
[settings.erlang]
compile = false
EOF

output="$(MISE_FRIENDLY_ERROR=1 RUST_BACKTRACE=0 ImageOS=nobara-43 mise install erlang@28.5 2>&1)" \
&& fail "expected erlang install to fail when precompiled binaries are unavailable"
Comment thread
risu729 marked this conversation as resolved.
Outdated

[[ $output == *"precompiled erlang is not available: unsupported OS version: nobara-43"* ]] \
|| fail "expected unsupported OS error, got: $output"

[[ $output != *"build-install"* ]] \
|| fail "erlang.compile=false should not fall back to kerl build-install: $output"
Comment thread
risu729 marked this conversation as resolved.
Outdated
47 changes: 30 additions & 17 deletions src/plugins/core/erlang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::lock_file::LockFile;
use crate::toolset::{ToolRequest, ToolVersion};
use crate::{file, github, plugins};
use async_trait::async_trait;
use eyre::Result;
use eyre::{Result, bail};
use xx::regex;

#[cfg(linux)]
Expand Down Expand Up @@ -84,6 +84,15 @@ impl ErlangPlugin {
Ok(())
}

fn precompiled_unavailable(&self, reason: impl Into<String>) -> Result<Option<ToolVersion>> {
let reason = reason.into();
if Settings::get().erlang.compile == Some(false) {
bail!("precompiled erlang is not available: {reason}");
}
debug!("{reason}");
Ok(None)
}

#[cfg(linux)]
async fn install_precompiled(
&self,
Expand All @@ -100,8 +109,7 @@ impl ErlangPlugin {
"x64" => "amd64".to_string(),
"arm64" => "arm64".to_string(),
other => {
debug!("Unsupported architecture: {}", other);
return Ok(None);
return self.precompiled_unavailable(format!("unsupported architecture: {other}"));
}
};

Expand All @@ -116,13 +124,12 @@ impl ErlangPlugin {
} else if let Ok(os_release) = &*os_release::OS_RELEASE {
os_ver = format!("{}-{}", os_release.id, os_release.version_id);
} else {
return Ok(None);
return self.precompiled_unavailable("could not determine OS release");
};

// Currently, Bob only builds for Ubuntu, so we have to check that we're on ubuntu, and on a supported version
if !["ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04"].contains(&os_ver.as_str()) {
debug!("Unsupported OS version: {}", os_ver);
return Ok(None);
return self.precompiled_unavailable(format!("unsupported OS version: {os_ver}"));
}

let url: String =
Expand Down Expand Up @@ -190,8 +197,8 @@ impl ErlangPlugin {
let gh_release = match github::get_release("erlef/otp_builds", &release_tag).await {
Ok(release) => release,
Err(e) => {
debug!("Failed to get release: {}", e);
return Ok(None);
return self
.precompiled_unavailable(format!("failed to get release {release_tag}: {e}"));
}
};
let settings = Settings::get();
Expand All @@ -208,8 +215,9 @@ impl ErlangPlugin {
let asset = match gh_release.assets.iter().find(|a| a.name == tarball_name) {
Some(asset) => asset,
None => {
debug!("No asset found for {}", release_tag);
return Ok(None);
return self.precompiled_unavailable(format!(
"no asset found for {tarball_name} in {release_tag}"
));
}
};
ctx.pr.set_message(format!("Downloading {tarball_name}"));
Expand Down Expand Up @@ -246,8 +254,8 @@ impl ErlangPlugin {
let gh_release = match github::get_release("erlang/otp", &release_tag).await {
Ok(release) => release,
Err(e) => {
debug!("Failed to get release: {}", e);
return Ok(None);
return self
.precompiled_unavailable(format!("failed to get release {release_tag}: {e}"));
}
};
let settings = Settings::get();
Expand All @@ -259,8 +267,9 @@ impl ErlangPlugin {
let asset = match gh_release.assets.iter().find(|a| a.name == zip_name) {
Some(asset) => asset,
None => {
debug!("No asset found for {}", release_tag);
return Ok(None);
return self.precompiled_unavailable(format!(
"no asset found for {zip_name} in {release_tag}"
));
}
};
ctx.pr.set_message(format!("Downloading {}", zip_name));
Expand All @@ -280,10 +289,14 @@ impl ErlangPlugin {
#[cfg(not(any(linux, macos, windows)))]
async fn install_precompiled(
&self,
ctx: &InstallContext,
tv: ToolVersion,
_ctx: &InstallContext,
_tv: ToolVersion,
) -> Result<Option<ToolVersion>> {
Ok(None)
if Settings::get().erlang.compile == Some(true) {
Ok(None)
} else {
self.precompiled_unavailable("precompiled erlang is not supported on this platform")
}
}

async fn install_via_kerl(
Expand Down
Loading