Skip to content

Commit ddba13f

Browse files
jdxclaude
andcommitted
fix(swift): fall back to Ubuntu 24.04 for unsupported Ubuntu versions
Swift only provides binaries for Ubuntu 20.04, 22.04, and 24.04. On newer Ubuntu versions (e.g. 26.04), the download URL would 404. Now maps unsupported Ubuntu versions to 24.04. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1a32edf commit ddba13f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/plugins/core/swift.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,11 @@ fn platform_directory() -> String {
279279
let settings = Settings::get();
280280
let arch = settings.arch();
281281
if os_release.id == "ubuntu" && arch == "arm64" {
282-
let retval = format!("{}{}-aarch64", os_release.id, os_release.version_id);
282+
let retval = format!(
283+
"{}{}-aarch64",
284+
os_release.id,
285+
ubuntu_swift_version(&os_release.version_id)
286+
);
283287
retval.replace(".", "")
284288
} else {
285289
platform().replace(".", "")
@@ -304,6 +308,8 @@ fn platform() -> String {
304308
"ubi9".to_string() // only 9 is available
305309
} else if os_release.id == "fedora" {
306310
"fedora39".to_string() // only 39 is available
311+
} else if os_release.id == "ubuntu" {
312+
format!("ubuntu{}", ubuntu_swift_version(&os_release.version_id))
307313
} else {
308314
format!("{}{}", os_release.id, os_release.version_id)
309315
}
@@ -336,6 +342,15 @@ fn architecture(settings: &Settings) -> Option<&str> {
336342
None
337343
}
338344

345+
/// Swift only provides Ubuntu binaries for specific versions.
346+
/// Map unsupported Ubuntu versions to the latest supported one.
347+
fn ubuntu_swift_version(version_id: &str) -> &str {
348+
match version_id {
349+
"20.04" | "22.04" | "24.04" => version_id,
350+
_ => "24.04",
351+
}
352+
}
353+
339354
fn url(tv: &ToolVersion) -> String {
340355
let settings = Settings::get();
341356
format!(

0 commit comments

Comments
 (0)