From 2abe6cda7aebef61794fefb3fb28ad5bab8bb158 Mon Sep 17 00:00:00 2001 From: peter madsen-mygdal Date: Sat, 14 Mar 2026 17:29:49 +0100 Subject: [PATCH] fix: download correct Gleam binary for macOS and Linux ARM64 (#428) The Gleam installer had two arch-related bugs: 1. Darwin reused the Linux config (installOpts.darwin = installOpts.linux), downloading x86_64-unknown-linux-musl on macOS, causing ENOEXEC. 2. Linux hardcoded x86_64, downloading the wrong binary on ARM64 runners, causing 'Syntax error' when trying to execute an x86_64 ELF. Add arch detection via getRunnerOSArchitecture() to both Linux and Darwin download URLs, selecting the correct aarch64 or x86_64 binary. Add a proper Darwin config that downloads apple-darwin archives. --- dist/index.js | 25 +++++++++++++++++++++++-- src/setup-beam.js | 25 +++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index e6f1440..a4371b0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -58558,12 +58558,14 @@ async function install(toolName, opts) { tool: 'Gleam', linux: { downloadToolURL: () => { + const arch = getRunnerOSArchitecture() let gz if ( versionSpec === 'nightly' || node_modules_semver.gt(versionSpec, 'v0.22.1') ) { - gz = `gleam-${versionSpec}-x86_64-unknown-linux-musl.tar.gz` + const target = arch === 'arm64' ? 'aarch64' : 'x86_64' + gz = `gleam-${versionSpec}-${target}-unknown-linux-musl.tar.gz` } else { gz = `gleam-${versionSpec}-linux-amd64.tar.gz` } @@ -58627,7 +58629,26 @@ async function install(toolName, opts) { }, }, } - installOpts.darwin = installOpts.linux + installOpts.darwin = { + downloadToolURL: () => { + const arch = getRunnerOSArchitecture() + let gz + if (versionSpec === 'nightly' || node_modules_semver.gt(versionSpec, 'v0.22.1')) { + const target = arch === 'arm64' ? 'aarch64' : 'x86_64' + gz = `gleam-${versionSpec}-${target}-apple-darwin.tar.gz` + } else { + gz = + arch === 'arm64' + ? `gleam-${versionSpec}-macos-arm64.tar.gz` + : `gleam-${versionSpec}-macos.tar.gz` + } + + return `https://github.com/gleam-lang/gleam/releases/download/${versionSpec}/${gz}` + }, + extract: installOpts.linux.extract, + postExtract: installOpts.linux.postExtract, + reportVersion: installOpts.linux.reportVersion, + } break case 'rebar3': installOpts = { diff --git a/src/setup-beam.js b/src/setup-beam.js index 0ce339f..7ac4c20 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -1051,12 +1051,14 @@ async function install(toolName, opts) { tool: 'Gleam', linux: { downloadToolURL: () => { + const arch = getRunnerOSArchitecture() let gz if ( versionSpec === 'nightly' || semver.gt(versionSpec, 'v0.22.1') ) { - gz = `gleam-${versionSpec}-x86_64-unknown-linux-musl.tar.gz` + const target = arch === 'arm64' ? 'aarch64' : 'x86_64' + gz = `gleam-${versionSpec}-${target}-unknown-linux-musl.tar.gz` } else { gz = `gleam-${versionSpec}-linux-amd64.tar.gz` } @@ -1120,7 +1122,26 @@ async function install(toolName, opts) { }, }, } - installOpts.darwin = installOpts.linux + installOpts.darwin = { + downloadToolURL: () => { + const arch = getRunnerOSArchitecture() + let gz + if (versionSpec === 'nightly' || semver.gt(versionSpec, 'v0.22.1')) { + const target = arch === 'arm64' ? 'aarch64' : 'x86_64' + gz = `gleam-${versionSpec}-${target}-apple-darwin.tar.gz` + } else { + gz = + arch === 'arm64' + ? `gleam-${versionSpec}-macos-arm64.tar.gz` + : `gleam-${versionSpec}-macos.tar.gz` + } + + return `https://github.com/gleam-lang/gleam/releases/download/${versionSpec}/${gz}` + }, + extract: installOpts.linux.extract, + postExtract: installOpts.linux.postExtract, + reportVersion: installOpts.linux.reportVersion, + } break case 'rebar3': installOpts = {