Skip to content

Commit c08ff4d

Browse files
fix: Add ARM64 architecture support for Linux CLI downloads [IDE-1473] (#734)
fix: Add ARM64 architecture support for Linux CLI downloads Fixes IDE-1473 IntelliJ on Linux ARM64 systems (aarch64) was incorrectly downloading snyk-linux instead of snyk-linux-arm64, causing Language Server initialization failures. Changes: - Added LINUX_ARM64 platform for snyk-linux-arm64 binary - Added LINUX_ALPINE_ARM64 platform for snyk-alpine-arm64 binary - Updated platform detection to check architecture (aarch64/arm64) - Enhanced tests to cover all Linux architecture combinations The plugin now correctly detects and downloads the appropriate CLI binary for: - Alpine + ARM64 → snyk-alpine-arm64 - ARM64 (non-Alpine) → snyk-linux-arm64 - Alpine (non-ARM64) → snyk-alpine - Regular Linux → snyk-linux
1 parent 2758adb commit c08ff4d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main/kotlin/io/snyk/plugin/cli/Platform.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class Platform(val snykWrapperFileName: String) {
88
companion object {
99
val LINUX = Platform("snyk-linux")
1010
val LINUX_ALPINE = Platform("snyk-alpine")
11+
val LINUX_ARM64 = Platform("snyk-linux-arm64")
12+
val LINUX_ALPINE_ARM64 = Platform("snyk-alpine-arm64")
1113
val MAC_OS = Platform("snyk-macos")
1214
val MAC_OS_ARM64 = Platform("snyk-macos-arm64")
1315
val WINDOWS = Platform("snyk-win.exe")
@@ -20,7 +22,17 @@ class Platform(val snykWrapperFileName: String) {
2022
val osName = (systemProperties["os.name"] as String).lowercase()
2123
val archName = (systemProperties["os.arch"] as String).lowercase()
2224
return when (osName) {
23-
"linux" -> if (Paths.get("/etc/alpine-release").toFile().exists()) LINUX_ALPINE else LINUX
25+
"linux" -> {
26+
val isAlpine = Paths.get("/etc/alpine-release").toFile().exists()
27+
val isArm64 = archName == "aarch64" || archName == "arm64"
28+
29+
when {
30+
isAlpine && isArm64 -> LINUX_ALPINE_ARM64
31+
isArm64 -> LINUX_ARM64
32+
isAlpine -> LINUX_ALPINE
33+
else -> LINUX
34+
}
35+
}
2436
"mac os x", "darwin", "osx" -> if (archName != "aarch64") MAC_OS else MAC_OS_ARM64
2537
else -> {
2638
if (osName.contains("windows")) {

src/test/kotlin/io/snyk/plugin/cli/PlatformTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ class PlatformTest {
1616
val linuxPlatform = Platform.detect(properties)
1717
assertTrue(Platform.LINUX == linuxPlatform || Platform.LINUX_ALPINE == linuxPlatform)
1818

19+
properties["os.name"] = "linux"
20+
properties["os.arch"] = "aarch64"
21+
val arm64Platform = Platform.detect(properties)
22+
assertTrue(Platform.LINUX_ARM64 == arm64Platform || Platform.LINUX_ALPINE_ARM64 == arm64Platform)
23+
24+
properties["os.name"] = "linux"
25+
properties["os.arch"] = "arm64"
26+
val arm64Platform2 = Platform.detect(properties)
27+
assertTrue(Platform.LINUX_ARM64 == arm64Platform2 || Platform.LINUX_ALPINE_ARM64 == arm64Platform2)
28+
1929
properties["os.name"] = "mac os x"
30+
properties["os.arch"] = "something"
2031
assertTrue(Platform.MAC_OS == Platform.detect(properties))
2132

2233
properties["os.name"] = "osx"

0 commit comments

Comments
 (0)