Skip to content

fix(cli): Normalize Linux ARM64 arch name for sentry-cli binary lookup#1201

Open
romtsn wants to merge 7 commits into
mainfrom
rz/fix/normalize-linux-arm64-arch
Open

fix(cli): Normalize Linux ARM64 arch name for sentry-cli binary lookup#1201
romtsn wants to merge 7 commits into
mainfrom
rz/fix/normalize-linux-arm64-arch

Conversation

@romtsn
Copy link
Copy Markdown
Member

@romtsn romtsn commented May 19, 2026

Summary

  • Normalize Linux architecture names in getCliSuffix() so that both arm64 and aarch64 JVM values resolve to the bundled sentry-cli-Linux-aarch64 binary
  • Also normalize x86_64 alongside the existing amd64 mapping for robustness
  • Add tests for arm64, aarch64, and x86_64 arch values

Fixes #1168

Test plan

  • Existing SentryCliProviderTest tests still pass
  • New test: os.arch=arm64 -> Linux-aarch64
  • New test: os.arch=aarch64 -> Linux-aarch64
  • New test: os.arch=x86_64 -> Linux-x86_64
  • Manually verify in Docker: docker build --platform linux/arm64 no longer fails to find sentry-cli

🤖 Generated with Claude Code

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>
romtsn and others added 2 commits May 19, 2026 14:04
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@runningcode runningcode left a comment

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we also now have windows aarch64 releases of the cli. should we fix that?

"x86_64" -> "x86_64"
"arm64",
"aarch64" -> "aarch64"
else -> osArch
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what about i686? Does that fall under else?

when (osArch) {
"amd64",
"x86_64" -> "x86_64"
"arm64",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't arm64 and aarch64 two separate binaries?

romtsn and others added 3 commits May 20, 2026 12:21
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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

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>
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.

"arm64" not normalized to "aarch64" when searching for sentry-cli binary

2 participants