Skip to content

Commit

Permalink
fix(swift): prevent swift from using linux platforms that are not ava…
Browse files Browse the repository at this point in the history
…ilable
  • Loading branch information
jdx committed Dec 15, 2024
1 parent 80d5b8d commit b890245
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,13 @@ env = "MISE_STATUS_MESSAGE_SHOW_TOOLS"
type = "Bool"
description = "Show configured env vars when entering a directory with a mise.toml file."

[swift.platform]
env = "MISE_SWIFT_PLATFORM"
type = "String"
optional = true
description = "Override the platform to use for precompiled binaries."
default_docs = '"osx" | "windows10" | "ubuntu20.04" | "ubuntu22.04" | "ubuntu24.04" | "amazonlinux2" | "ubi9" | "fedora39"'

[swift.gpg_verify]
env = "MISE_SWIFT_GPG_VERIFY"
type = "Bool"
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/core/swift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,25 @@ fn platform_directory() -> String {
}

fn platform() -> String {
if let Some(platform) = &*SETTINGS.swift.platform {
return platform.clone();
}
if cfg!(macos) {
"osx".to_string()
} else if cfg!(windows) {
"windows10".to_string()
} else if let Ok(os_release) = &*os_release::OS_RELEASE {
if os_release.id == "amzn" {
format!("amazonlinux{}", os_release.version_id)
} else if os_release.id == "ubi" {
"ubi9".to_string() // only 9 is available
} else if os_release.id == "fedora" {
"fedora39".to_string() // only 39 is available
} else {
format!("{}{}", os_release.id, os_release.version_id)
}
} else {
"ubi".to_string()
"ubi9".to_string()
}
}

Expand Down

0 comments on commit b890245

Please sign in to comment.