fix(cli): Normalize Linux ARM64 arch name for sentry-cli binary lookup#1201
fix(cli): Normalize Linux ARM64 arch name for sentry-cli binary lookup#1201romtsn wants to merge 7 commits into
Conversation
The JVM can report `os.arch` as `"arm64"` on some systems (e.g., Docker on Apple Silicon), but the bundled binary is named `sentry-cli-Linux-aarch64`. Normalize both ARM (`arm64`/`aarch64`) and x86 (`amd64`/`x86_64`) arch names to match the bundled binary naming convention. Fixes #1168 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
runningcode
left a comment
There was a problem hiding this comment.
Should we take a look at https://github.com/getsentry/sentry-cli/releases/tag/3.4.2 and make sure we support all the different releases correctly here?
| @@ -134,7 +134,17 @@ internal object SentryCliProvider { | |||
| val osArch = System.getProperty("os.arch") | |||
| return when { | |||
| "mac" in osName -> "Darwin-universal" | |||
There was a problem hiding this comment.
Unrelated to this PR, but since the universal binary is twice the size of the others, wouldn't it be better for performance if we used the platform specific binary on mac?
| } | ||
| "Linux-$normalizedArch" | ||
| } | ||
| "win" in osName -> "Windows-i686.exe" |
There was a problem hiding this comment.
we also now have windows aarch64 releases of the cli. should we fix that?
| "x86_64" -> "x86_64" | ||
| "arm64", | ||
| "aarch64" -> "aarch64" | ||
| else -> osArch |
There was a problem hiding this comment.
what about i686? Does that fall under else?
| when (osArch) { | ||
| "amd64", | ||
| "x86_64" -> "x86_64" | ||
| "arm64", |
There was a problem hiding this comment.
isn't arm64 and aarch64 two separate binaries?
Expand platform coverage to match sentry-cli release binaries: - Download and support Windows-x86_64 and Windows-aarch64 binaries - Normalize Linux i386/i686 arch names - Add tests for all new arch mappings Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Download Linux-armv7 binary from sentry-cli releases - Normalize JVM arch values "arm" and "armv7l" to "armv7" - Replace incorrect armV7 test with arm and armv7l tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace Darwin-universal (26MB) with Darwin-arm64 (12MB) and Darwin-x86_64 (14MB) for smaller extracted binary at runtime. JAR size stays the same since both are bundled. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| "mac" in osName -> "Darwin-universal" | ||
| "linux" in osName -> if (osArch == "amd64") "Linux-x86_64" else "Linux-$osArch" | ||
| "win" in osName -> "Windows-i686.exe" | ||
| "mac" in osName -> if (osArch == "aarch64") "Darwin-arm64" else "Darwin-x86_64" |
There was a problem hiding this comment.
Bug: The architecture check for Apple Silicon is incomplete. It only checks for "aarch64" while native ARM JVMs report "arm64", causing the wrong binary to be selected.
Severity: HIGH
Suggested Fix
Update the condition to handle both "aarch64" and "arm64" for macOS, similar to how it's handled for Linux and Windows. Change if (osArch == "aarch64") to if (osArch == "aarch64" || osArch == "arm64").
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
plugin-build/src/main/kotlin/io/sentry/android/gradle/SentryCliProvider.kt#L136
Potential issue: On macOS with Apple Silicon (M1/M2/M3) and a native ARM64 JVM, the
system property `os.arch` is reported as `"arm64"`. The current code in `getCliSuffix()`
only checks if `osArch == "aarch64"`. This condition fails, causing the `else` branch to
incorrectly return `"Darwin-x86_64"` instead of `"Darwin-arm64"`. This will lead to
failures when trying to execute the Sentry CLI on modern Mac setups, as the wrong binary
architecture will be used.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 25139c1. Configure here.
| "mac" in osName -> "Darwin-universal" | ||
| "linux" in osName -> if (osArch == "amd64") "Linux-x86_64" else "Linux-$osArch" | ||
| "win" in osName -> "Windows-i686.exe" | ||
| "mac" in osName -> if (osArch == "aarch64") "Darwin-arm64" else "Darwin-x86_64" |
There was a problem hiding this comment.
macOS omits arm64 arch alias
Medium Severity
In getCliSuffix(), the macOS branch only treats os.arch aarch64 as Apple Silicon, while Linux and Windows in the same change map both arm64 and aarch64 to the bundled ARM CLI. If a Mac JVM reports arm64, the code picks Darwin-x86_64 instead of Darwin-arm64, so the wrong bundled sentry-cli may be used or missing.
Reviewed by Cursor Bugbot for commit 25139c1. Configure here.
Revert Windows arch detection and Linux armv7/i386 normalization — Windows i686 works on all Windows archs via WoW64, and armv7/i386 are too niche to justify the JAR size increase. Keep macOS platform-specific binaries and Linux arm64 fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>


Summary
getCliSuffix()so that botharm64andaarch64JVM values resolve to the bundledsentry-cli-Linux-aarch64binaryx86_64alongside the existingamd64mapping for robustnessarm64,aarch64, andx86_64arch valuesFixes #1168
Test plan
SentryCliProviderTesttests still passos.arch=arm64->Linux-aarch64os.arch=aarch64->Linux-aarch64os.arch=x86_64->Linux-x86_64docker build --platform linux/arm64no longer fails to find sentry-cli🤖 Generated with Claude Code