fix(core): respect MISE_ARCH override in bun and erlang plugins#8062
fix(core): respect MISE_ARCH override in bun and erlang plugins#8062
Conversation
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>
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| "x64" => "x86_64", | ||
| "arm64" => "aarch64", | ||
| other => other, | ||
| }; | ||
| let os = match settings.os() { | ||
| "macos" => "apple-darwin", | ||
| other => other, |
There was a problem hiding this comment.
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.
| "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); | |
| } |
| let settings = Settings::get(); | ||
| let os = match settings.os() { | ||
| "windows" => "win64", | ||
| other => other, |
There was a problem hiding this comment.
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.
| 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); | |
| } |
| 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(), | ||
| } |
There was a problem hiding this comment.
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.
| fn os() -> String { | ||
| let settings = Settings::get(); | ||
| BunPlugin::map_os_to_bun(settings.os()).to_string() |
There was a problem hiding this comment.
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.
| 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()) |
There was a problem hiding this comment.
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.
| 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() | ||
| } |
There was a problem hiding this comment.
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.
| 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 | |
| } |
Hyperfine Performance
|
| 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% |
### 🚀 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)
…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>
### 🚀 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)
Summary
cfg!(target_arch)checks withSettings::get().arch()in bun and erlang core plugins so thatMISE_ARCHenvironment variable overrides are respected at runtimecfg!(target_os)/ hardcoded OS constants withSettings::get().os()for consistency with other plugins (node, python, java, ruby, rust, swift)Test plan
mise run lint-fixpassesmise run buildcompiles successfully (via cargo-check in lint)mise run test:unit— all 461 tests passMISE_ARCH=x64on 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)/staticARCH/OSusage withSettings::get().arch()andSettings::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-baselinewhenSettingsreportsarm64on Windows (to support x64-under-emulation), and Erlang’s precompiled asset naming now mapsSettingsarch/OS values to the expected release artifact names and removes the old hardcodedARCH/OSconstants.Written by Cursor Bugbot for commit 026c4f6. This will update automatically on new commits. Configure here.