Skip to content

fix(core): respect MISE_ARCH override in bun and erlang plugins#8062

Merged
jdx merged 1 commit intomainfrom
fix/mise-arch-core-plugins
Feb 8, 2026
Merged

fix(core): respect MISE_ARCH override in bun and erlang plugins#8062
jdx merged 1 commit intomainfrom
fix/mise-arch-core-plugins

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Feb 8, 2026

Summary

  • Replace compile-time cfg!(target_arch) checks with Settings::get().arch() in bun and erlang core plugins so that MISE_ARCH environment variable overrides are respected at runtime
  • This enables Windows ARM64 users to opt into x64 bun builds under Prism emulation (ref: [Bug] Bun on Windows ARM64 fails to run - should download x64-baseline build instead of x64 #7155)
  • Also replaces cfg!(target_os) / hardcoded OS constants with Settings::get().os() for consistency with other plugins (node, python, java, ruby, rust, swift)

Test plan

  • mise run lint-fix passes
  • mise run build compiles successfully (via cargo-check in lint)
  • mise run test:unit — all 461 tests pass
  • Manual verification: set MISE_ARCH=x64 on an ARM64 system and confirm bun installs the x64-baseline variant

🤖 Generated with Claude Code


Note

Medium Risk
Changes alter platform/variant string construction that directly controls which prebuilt archives are downloaded and written into lockfiles; incorrect mapping could break installs on specific OS/arch combinations, especially Windows/ARM64 and musl/baseline variants.

Overview
Bun and Erlang installs now respect runtime arch/OS overrides. The Bun plugin replaces compile-time cfg!(target_arch)/static ARCH/OS usage with Settings::get().arch() and Settings::get().os() when building download URLs and platform keys, while still using runtime AVX2 and compile-time musl detection for bun variant selection.

Improves cross-arch behavior on Windows ARM64. Bun’s arch resolution now explicitly falls back to x64-baseline when Settings reports arm64 on Windows (to support x64-under-emulation), and Erlang’s precompiled asset naming now maps Settings arch/OS values to the expected release artifact names and removes the old hardcoded ARCH/OS constants.

Written by Cursor Bugbot for commit 026c4f6. This will update automatically on new commits. Configure here.

Bun and erlang core plugins used compile-time cfg!(target_arch) checks
instead of Settings::get().arch(), causing MISE_ARCH overrides to be
silently ignored. This is needed for Windows ARM64 users who want to
use the x64 bun build under Prism emulation (GitHub discussion #7155).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 8, 2026 19:10
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jdx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the mise tool's flexibility by shifting architecture and operating system detection from compile-time to runtime for the Bun and Erlang plugins. This change allows users to override the detected system architecture and OS using environment variables like MISE_ARCH, which is crucial for scenarios such as running x64 builds on ARM64 systems via emulation. It also promotes consistency in how plugins determine system properties.

Highlights

  • Runtime Arch/OS Overrides: Replaced compile-time cfg!(target_arch) and cfg!(target_os) checks with runtime Settings::get().arch() and Settings::get().os() in Bun and Erlang plugins.
  • MISE_ARCH Support: Enabled MISE_ARCH environment variable to override the detected architecture, allowing greater flexibility for users, such as Windows ARM64 users to opt into x64 Bun builds under emulation.
  • Plugin Consistency: Standardized architecture and OS detection across plugins by using Settings::get().arch() and Settings::get().os(), aligning Bun and Erlang with other core plugins like Node, Python, and Java.
Changelog
  • src/plugins/core/bun.rs
    • Removed direct imports of ARCH and OS constants from crate::cli::version.
    • Updated get_platform_variant and get_bun_arch_with_variants functions to dynamically retrieve architecture and OS from Settings::get(), supporting MISE_ARCH overrides and handling specific platform fallbacks (e.g., Windows ARM64 to x64-baseline for Bun).
    • Modified os() and arch() helper functions to use Settings::get() for runtime values.
  • src/plugins/core/erlang.rs
    • Adjusted logic in install_version and fetch_remote_versions to utilize Settings::get().arch() and Settings::get().os() for constructing release asset names, ensuring MISE_ARCH and MISE_OS are respected.
    • Removed previously hardcoded ARCH and OS constants.
Activity
  • mise run lint-fix passed.
  • mise run build compiled successfully.
  • All 461 unit tests (mise run test:unit) passed.
  • Manual verification for MISE_ARCH=x64 on ARM64 for Bun installation is pending.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates Bun and Erlang core plugins to use runtime Settings OS/arch detection (respecting MISE_ARCH overrides) instead of compile-time cfg!() / constants, improving cross-arch behavior (notably Windows ARM64 opting into x64 builds).

Changes:

  • Switch Erlang and Bun plugins from compile-time arch/OS checks to Settings::get().arch() / Settings::get().os()
  • Remove Erlang-local arch/OS constants and adapt asset naming to settings-derived values
  • Update Bun’s arch selection logic to incorporate settings + runtime capability detection (musl/AVX2)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/plugins/core/erlang.rs Uses Settings for arch/OS and adjusts GitHub asset name construction accordingly
src/plugins/core/bun.rs Uses Settings for arch/OS and updates Bun download-arch selection to honor MISE_ARCH

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +201 to +207
"x64" => "x86_64",
"arm64" => "aarch64",
other => other,
};
let os = match settings.os() {
"macos" => "apple-darwin",
other => other,
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

Unlike the earlier arch mapping (which returns Ok(None) for unsupported values), this tarball-name mapping passes unknown arch/os values through directly. If Settings::get().arch() or Settings::get().os() yields something not matching the upstream asset naming scheme (including common synonyms like amd64/x86_64 or windows), the plugin will silently construct an invalid asset name and fail to find the release asset. Consider making this mapping strict (explicitly map supported values and otherwise log + Ok(None)), or centralize the mapping in a single helper used by both code paths to keep behavior consistent.

Suggested change
"x64" => "x86_64",
"arm64" => "aarch64",
other => other,
};
let os = match settings.os() {
"macos" => "apple-darwin",
other => other,
// Normalize common synonyms to upstream naming.
"x64" | "x86_64" => "x86_64",
"arm64" | "aarch64" => "aarch64",
other => {
debug!(
"Unsupported architecture '{}' for prebuilt Erlang tarball; falling back to compilation or other install methods",
other
);
return Ok(None);
}
};
let os = match settings.os() {
// Normalize macOS naming to upstream convention.
"macos" | "darwin" => "apple-darwin",
// Known-good values that match upstream asset naming.
"linux" => "linux",
"windows" => "windows",
other => {
debug!(
"Unsupported OS '{}' for prebuilt Erlang tarball; falling back to compilation or other install methods",
other
);
return Ok(None);
}

Copilot uses AI. Check for mistakes.
let settings = Settings::get();
let os = match settings.os() {
"windows" => "win64",
other => other,
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

This changes behavior for non-Windows OS values: previously the OS constant used apple-darwin on macOS, but now macOS would become otp_macos_<version>.zip (due to pass-through). If this zip asset path is ever used outside Windows, it will likely search for the wrong asset name. Even if the zip path is intended to be Windows-only, it’s safer to handle supported OS values explicitly (e.g., map macOS/linux as needed or return Ok(None) when settings.os() != \"windows\") to avoid silent mismatches.

Suggested change
other => other,
_ => {
// Precompiled OTP zip assets are only supported on Windows.
// For other OS values, fall back to the non-precompiled path.
return Ok(None);
}

Copilot uses AI. Check for mistakes.
Comment on lines +387 to 412
match arch {
"x64" => {
if Self::is_musl() {
if Self::has_avx2() {
"x64-musl".to_string()
} else {
"x64-musl-baseline".to_string()
}
} else if Self::has_avx2() {
"x64".to_string()
} else {
"x64-musl-baseline"
"x64-baseline".to_string()
}
} else if Self::has_avx2() {
"x64"
} else {
"x64-baseline"
}
} else if cfg!(target_arch = "aarch64") {
if Self::is_musl() {
"aarch64-musl"
} else if cfg!(windows) {
"x64-baseline"
} else {
"aarch64"
"arm64" => {
if Self::is_musl() {
"aarch64-musl".to_string()
} else if os == "windows" {
// Bun has no native windows-arm64 build; fall back to x64 under emulation
"x64-baseline".to_string()
} else {
"aarch64".to_string()
}
}
} else {
&ARCH
other => other.to_string(),
}
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

The fallback other => other.to_string() will propagate arbitrary MISE_ARCH values directly into Bun download identifiers. If a user sets MISE_ARCH to common non-mise labels (e.g., x86_64, amd64, aarch64), this will likely generate invalid Bun artifact names/URLs. Consider normalizing common synonyms into the expected Bun values (e.g., x86_64|amd64 -> x64, aarch64 -> arm64) and/or rejecting unsupported values with a clear log message.

Copilot uses AI. Check for mistakes.
Comment on lines +416 to +418
fn os() -> String {
let settings = Settings::get();
BunPlugin::map_os_to_bun(settings.os()).to_string()
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

os() now allocates a new String even though map_os_to_bun(...) appears to return a borrowed/static string. If this is called frequently (e.g., during URL construction), consider returning &'static str (or a Cow<'static, str>) here to avoid repeated allocations, since the OS mapping doesn’t need to be owned.

Suggested change
fn os() -> String {
let settings = Settings::get();
BunPlugin::map_os_to_bun(settings.os()).to_string()
fn os() -> &'static str {
let settings = Settings::get();
BunPlugin::map_os_to_bun(settings.os())

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly replaces compile-time architecture and OS checks with runtime values from Settings, enabling overrides via environment variables like MISE_ARCH. The changes in bun.rs and erlang.rs are well-implemented and achieve the intended goal. I have one suggestion for bun.rs to optimize performance by caching the results of the os() and arch() functions, which are called multiple times during installation.

Comment on lines +416 to 423
fn os() -> String {
let settings = Settings::get();
BunPlugin::map_os_to_bun(settings.os()).to_string()
}

fn arch() -> &'static str {
fn arch() -> String {
BunPlugin::get_bun_arch_with_variants()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The os() and arch() functions are called multiple times during the installation process (in download() and install()). This leads to repeated calls to Settings::get() and string allocations. To improve performance and avoid redundant computations, you can cache the results using std::sync::LazyLock (aliased as Lazy). This will compute the values once and reuse them, and also allows the functions to return &'static str again, which is more efficient.

You will need to add use std::sync::LazyLock as Lazy; at the top of the file.

Suggested change
fn os() -> String {
let settings = Settings::get();
BunPlugin::map_os_to_bun(settings.os()).to_string()
}
fn arch() -> &'static str {
fn arch() -> String {
BunPlugin::get_bun_arch_with_variants()
}
static OS: Lazy<String> = Lazy::new(|| {
let settings = Settings::get();
BunPlugin::map_os_to_bun(settings.os()).to_string()
});
static ARCH: Lazy<String> = Lazy::new(BunPlugin::get_bun_arch_with_variants);
fn os() -> &'static str {
&OS
}
fn arch() -> &'static str {
&ARCH
}

@github-actions
Copy link

github-actions bot commented Feb 8, 2026

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.7 x -- echo 20.6 ± 0.3 20.0 23.2 1.00
mise x -- echo 21.6 ± 0.3 21.1 22.8 1.04 ± 0.02

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.7 env 20.3 ± 0.7 19.4 25.5 1.00
mise env 21.0 ± 0.6 20.5 32.6 1.03 ± 0.05

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.7 hook-env 20.8 ± 0.2 20.4 21.8 1.00
mise hook-env 22.3 ± 0.7 21.2 31.0 1.07 ± 0.04

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.7 ls 19.3 ± 0.5 18.5 20.6 1.00
mise ls 20.4 ± 0.7 19.3 22.7 1.06 ± 0.05

xtasks/test/perf

Command mise-2026.2.7 mise Variance
install (cached) 118ms 118ms +0%
ls (cached) 71ms 71ms +0%
bin-paths (cached) 75ms 76ms -1%
task-ls (cached) 531ms 534ms +0%

@jdx jdx merged commit c671053 into main Feb 8, 2026
37 checks passed
@jdx jdx deleted the fix/mise-arch-core-plugins branch February 8, 2026 19:27
mise-en-dev added a commit that referenced this pull request Feb 9, 2026
### 🚀 Features

- **(node)** support package.json as idiomatic version file by @jdx in
[#8059](#8059)
- **(ruby)** graduate precompiled ruby from experimental (gradual
rollout) by @jdx in [#8052](#8052)
- add --dry-run-code flag to exit non-zero when there is work to do by
@jdx in [#8063](#8063)

### 🐛 Bug Fixes

- **(core)** respect MISE_ARCH override in bun and erlang plugins by
@jdx in [#8062](#8062)
- **(hooks)** resolve 12 community-reported hooks issues by @jdx in
[#8058](#8058)
- accept key=value format in set/add subcommands by @jdx in
[#8053](#8053)

### 📚 Documentation

- bump action versions in GitHub Actions examples by @muzimuzhi in
[#8065](#8065)
- add opengraph meta tags by @jdx in
[#8066](#8066)

### 📦️ Dependency Updates

- upgrade toml to 0.9 and toml_edit to 0.24 (TOML 1.1) by @jdx in
[#8057](#8057)

### 📦 Registry

- add quicktype (npm:quicktype) by @zdunecki in
[#8054](#8054)
- use inline table for test definitions by @jdx in
[#8056](#8056)
lucasew pushed a commit to lucasew/CONTRIB-mise that referenced this pull request Feb 18, 2026
…8062)

## Summary
- Replace compile-time `cfg!(target_arch)` checks with
`Settings::get().arch()` in bun and erlang core plugins so that
`MISE_ARCH` environment variable overrides are respected at runtime
- This enables Windows ARM64 users to opt into x64 bun builds under
Prism emulation (ref: jdx#7155)
- Also replaces `cfg!(target_os)` / hardcoded OS constants with
`Settings::get().os()` for consistency with other plugins (node, python,
java, ruby, rust, swift)

## Test plan
- [x] `mise run lint-fix` passes
- [x] `mise run build` compiles successfully (via cargo-check in lint)
- [x] `mise run test:unit` — all 461 tests pass
- [ ] Manual verification: set `MISE_ARCH=x64` on an ARM64 system and
confirm bun installs the x64-baseline variant

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes alter platform/variant string construction that directly
controls which prebuilt archives are downloaded and written into
lockfiles; incorrect mapping could break installs on specific OS/arch
combinations, especially Windows/ARM64 and musl/baseline variants.
> 
> **Overview**
> **Bun and Erlang installs now respect runtime arch/OS overrides.** The
Bun plugin replaces compile-time `cfg!(target_arch)`/static `ARCH`/`OS`
usage with `Settings::get().arch()` and `Settings::get().os()` when
building download URLs and platform keys, while still using runtime AVX2
and compile-time musl detection for bun variant selection.
> 
> **Improves cross-arch behavior on Windows ARM64.** Bun’s arch
resolution now explicitly falls back to `x64-baseline` when `Settings`
reports `arm64` on Windows (to support x64-under-emulation), and
Erlang’s precompiled asset naming now maps `Settings` arch/OS values to
the expected release artifact names and removes the old hardcoded
`ARCH`/`OS` constants.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
026c4f6. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
lucasew pushed a commit to lucasew/CONTRIB-mise that referenced this pull request Feb 18, 2026
### 🚀 Features

- **(node)** support package.json as idiomatic version file by @jdx in
[jdx#8059](jdx#8059)
- **(ruby)** graduate precompiled ruby from experimental (gradual
rollout) by @jdx in [jdx#8052](jdx#8052)
- add --dry-run-code flag to exit non-zero when there is work to do by
@jdx in [jdx#8063](jdx#8063)

### 🐛 Bug Fixes

- **(core)** respect MISE_ARCH override in bun and erlang plugins by
@jdx in [jdx#8062](jdx#8062)
- **(hooks)** resolve 12 community-reported hooks issues by @jdx in
[jdx#8058](jdx#8058)
- accept key=value format in set/add subcommands by @jdx in
[jdx#8053](jdx#8053)

### 📚 Documentation

- bump action versions in GitHub Actions examples by @muzimuzhi in
[jdx#8065](jdx#8065)
- add opengraph meta tags by @jdx in
[jdx#8066](jdx#8066)

### 📦️ Dependency Updates

- upgrade toml to 0.9 and toml_edit to 0.24 (TOML 1.1) by @jdx in
[jdx#8057](jdx#8057)

### 📦 Registry

- add quicktype (npm:quicktype) by @zdunecki in
[jdx#8054](jdx#8054)
- use inline table for test definitions by @jdx in
[jdx#8056](jdx#8056)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants