Skip to content

fix(swift): fall back to Ubuntu 24.04 for unsupported Ubuntu versions#8916

Merged
jdx merged 1 commit intomainfrom
fix/swift-ubuntu-platform
Apr 4, 2026
Merged

fix(swift): fall back to Ubuntu 24.04 for unsupported Ubuntu versions#8916
jdx merged 1 commit intomainfrom
fix/swift-ubuntu-platform

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Apr 4, 2026

Summary

  • Swift only provides binaries for Ubuntu 20.04, 22.04, and 24.04
  • On Ubuntu 26.04, the download URL 404s (ubuntu26.04 is not a valid Swift platform)
  • Map unsupported Ubuntu versions to 24.04 (latest supported), matching the existing pattern for Fedora and UBI

Test plan

  • Verified https://download.swift.org/.../ubuntu24.04.tar.gz returns 200
  • Verified https://download.swift.org/.../ubuntu26.04.tar.gz redirects to 404

🤖 Generated with Claude Code


Note

Low Risk
Low risk: small, isolated change to Swift download URL/platform selection for Ubuntu; main risk is incorrect version mapping causing downloads to target the wrong Ubuntu build.

Overview
Adjusts Swift Linux platform resolution so Ubuntu uses a supported Swift binary version: introduces ubuntu_swift_version() to map unknown version_ids to 24.04.

This mapping is applied both to platform() (e.g., ubuntu24.04) and to the Ubuntu arm64 platform_directory() string (e.g., ubuntu2404-aarch64), preventing 404s when running on newer/unsupported Ubuntu releases.

Reviewed by Cursor Bugbot for commit ddba13f. Bugbot is set up for automated code reviews on this repo. Configure here.

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>
@jdx jdx force-pushed the fix/swift-ubuntu-platform branch from 302c2b2 to ddba13f Compare April 4, 2026 22:07
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds pkg-config to the E2E Dockerfile and introduces a mapping function for Ubuntu versions in the Swift plugin to ensure compatibility with available Swift binaries. A suggestion was made to refine the Ubuntu version mapping logic to better handle older and newer versions by setting a baseline and a cap.

Comment on lines +347 to +352
fn ubuntu_swift_version(version_id: &str) -> &str {
match version_id {
"20.04" | "22.04" | "24.04" => version_id,
_ => "24.04",
}
}
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.

medium

Instead of maintaining support for very old Ubuntu versions (like 18.04) through complex mapping, we should define a minimum supported version. This aligns with our policy of avoiding complex backward-compatibility logic for platforms older than 7 years. Consider defaulting unrecognized older versions to a baseline supported version like 20.04.

Suggested change
fn ubuntu_swift_version(version_id: &str) -> &str {
match version_id {
"20.04" | "22.04" | "24.04" => version_id,
_ => "24.04",
}
}
fn ubuntu_swift_version(version_id: &str) -> &str {
match version_id {
"20.04" | "22.04" | "24.04" => version_id,
v if v > "24.04" => "24.04",
_ => "20.04",
}
}
References
  1. When interacting with external tools, consider removing compatibility checks for very old versions (e.g., 7+ years old) if modern versions handle the functionality gracefully. Prefer documenting the minimum supported version over implementing complex backward-compatibility logic.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 4, 2026

Greptile Summary

This PR fixes Swift installation on Ubuntu versions not officially supported by Swift's binary distribution (e.g., Ubuntu 26.04) by adding an ubuntu_swift_version() helper that maps any unsupported version to the latest supported release (24.04), matching the existing hardcoding pattern already used for Fedora and UBI.

  • Adds ubuntu_swift_version(version_id: &str) -> &str which passes through 20.04, 22.04, and 24.04 unchanged and falls back to 24.04 for everything else
  • Applied consistently in both platform() (new ubuntu-specific branch) and platform_directory() (arm64 path), keeping the two in sync
  • url() and verify_gpg() both derive from these functions, so the corrected version propagates to the tarball URL and the GPG signature URL alike
  • No unit tests were added for the new helper, despite the file already containing a mod tests block with tests for other pure functions

Confidence Score: 5/5

Safe to merge; the fix is minimal, correct, and non-breaking for all currently supported Ubuntu versions

Single-file change with a simple pure mapping function. Supported Ubuntu versions (20.04/22.04/24.04) pass through unchanged, so no regression for existing users. Unsupported versions now resolve to a valid Swift binary URL instead of 404ing. Logic is consistent between platform() and platform_directory(). Matches the established pattern used for Fedora and UBI hardcoding.

No files require special attention

Important Files Changed

Filename Overview
src/plugins/core/swift.rs Adds ubuntu_swift_version() helper to map unsupported Ubuntu versions to 24.04; correctly applied in both platform() and platform_directory(), no regressions for currently-supported versions

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Install Swift on Linux] --> B{os_release.id?}
    B -->|ubuntu| C[ubuntu_swift_version\nversion_id]
    B -->|amzn| D[amazonlinuxVER]
    B -->|ubi| E[ubi9 hardcoded]
    B -->|fedora| F[fedora39 hardcoded]
    B -->|other| G[id + version_id]
    C --> H{version_id\nin 20.04 / 22.04 / 24.04?}
    H -->|yes| I[use version_id as-is]
    H -->|no e.g. 26.04| J[fallback → 24.04]
    I --> K[Build tarball + sig URL]
    J --> K
    D --> K
    E --> K
    F --> K
    G --> K
Loading

Fix All in Claude Code

Reviews (1): Last reviewed commit: "fix(swift): fall back to Ubuntu 24.04 fo..." | Re-trigger Greptile

Comment on lines +347 to +352
fn ubuntu_swift_version(version_id: &str) -> &str {
match version_id {
"20.04" | "22.04" | "24.04" => version_id,
_ => "24.04",
}
}
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.

P2 Consider adding unit tests for ubuntu_swift_version

The file already has a mod tests block (used for resolve_pkgutil_path). ubuntu_swift_version is a pure function — boundary cases like "20.04", "22.04", "24.04", and "26.04" are trivial to assert and would guard against accidental future edits (e.g., adding "18.04" support or changing the fallback version).

Suggested change
fn ubuntu_swift_version(version_id: &str) -> &str {
match version_id {
"20.04" | "22.04" | "24.04" => version_id,
_ => "24.04",
}
}
/// Swift only provides Ubuntu binaries for specific versions.
/// Map unsupported Ubuntu versions to the latest supported one.
fn ubuntu_swift_version(version_id: &str) -> &str {
match version_id {
"20.04" | "22.04" | "24.04" => version_id,
_ => "24.04",
}
}
#[cfg(test)]
mod ubuntu_version_tests {
use super::ubuntu_swift_version;
#[test]
fn supported_versions_pass_through() {
assert_eq!(ubuntu_swift_version("20.04"), "20.04");
assert_eq!(ubuntu_swift_version("22.04"), "22.04");
assert_eq!(ubuntu_swift_version("24.04"), "24.04");
}
#[test]
fn unsupported_version_falls_back_to_24_04() {
assert_eq!(ubuntu_swift_version("26.04"), "24.04");
assert_eq!(ubuntu_swift_version("18.04"), "24.04");
assert_eq!(ubuntu_swift_version("99.99"), "24.04");
}
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds pkg-config to the E2E Dockerfile and updates the Swift plugin to correctly handle Ubuntu version mapping for binary downloads. It introduces a helper function to map unsupported Ubuntu versions to the nearest supported release, defaulting to 24.04. I have no feedback to provide as there were no review comments.

@jdx jdx merged commit 3948d84 into main Apr 4, 2026
36 checks passed
@jdx jdx deleted the fix/swift-ubuntu-platform branch April 4, 2026 22:27
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.4.3 x -- echo 21.4 ± 0.3 21.0 24.5 1.00
mise x -- echo 21.9 ± 0.4 21.3 24.8 1.02 ± 0.02

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.4.3 env 21.0 ± 0.4 20.4 25.5 1.00
mise env 21.3 ± 0.2 20.7 22.8 1.01 ± 0.02

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.4.3 hook-env 21.6 ± 0.2 21.1 24.5 1.00
mise hook-env 22.0 ± 0.3 21.5 25.2 1.02 ± 0.02

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.4.3 ls 19.0 ± 0.4 18.5 24.3 1.00
mise ls 19.4 ± 0.2 19.0 22.8 1.02 ± 0.02

xtasks/test/perf

Command mise-2026.4.3 mise Variance
install (cached) 145ms 146ms +0%
ls (cached) 76ms 76ms +0%
bin-paths (cached) 80ms 80ms +0%
task-ls (cached) 823ms 790ms +4%

jdx pushed a commit that referenced this pull request Apr 5, 2026
### 🚀 Features

- **(ci)** auto-convert external PRs to draft mode by @jdx in
[#8896](#8896)
- **(deps)** add `depends` field for user-specified tool dependencies by
@cprecioso in [#8776](#8776)
- **(dotnet)** support runtime-only installs by @fragon10 in
[#8524](#8524)
- **(npm)** apply install_before to transitive dependencies by @risu729
in [#8851](#8851)
- **(task)** allow passing arguments to task dependencies via
{{usage.*}} templates by @jdx in
[#8893](#8893)
- add options field to BackendListVersionsCtx by @esteve in
[#8875](#8875)

### 🐛 Bug Fixes

- **(backend)** filter PEP 440 .dev versions in fuzzy version matching
by @richardthe3rd in [#8849](#8849)
- **(ci)** update COPR BuildRequires rust version to match MSRV 1.88 by
@jdx in [#8911](#8911)
- **(ci)** add Ruby build dependencies to e2e Docker image by @jdx in
[#8910](#8910)
- **(ci)** add missing build dependencies to e2e Docker image by @jdx in
[#8912](#8912)
- **(ci)** add missing build dependencies to e2e Docker image by @jdx in
[#8914](#8914)
- **(ci)** use Node 24 LTS for corepack e2e test by @jdx in
[#8915](#8915)
- **(ci)** add libxml2 and pkg-config to e2e Docker image by @jdx in
[#8917](#8917)
- **(ci)** add libxml2-dev to e2e image and disable Swift SPM tests by
@jdx in [#8918](#8918)
- **(docs)** use sans-serif font for badges by @jdx in
[#8887](#8887)
- **(env)** parse --env=VALUE and -E=VALUE flag forms correctly by @jdx
in [#8889](#8889)
- **(exec)** use i64::from() for seccomp syscall numbers to survive
autofix by @jdx in [#8882](#8882)
- **(github)** preserve tool options like filter_bins when version
specified via CLI by @jdx in
[#8888](#8888)
- **(github)** use alias-specific options when tool_alias has its own
config by @jdx in [#8892](#8892)
- **(install)** add locked_verify_provenance setting and detect github
attestations at lock time by @jdx in
[#8901](#8901)
- **(lock)** prune stale version entries during filtered `mise lock
<tool>` runs by @altendky in
[#8599](#8599)
- **(python)** use lockfile URL for precompiled installs by @hehaoqian
in [#8750](#8750)
- **(release)** verify all build targets succeed before releasing by
@jdx in [#8886](#8886)
- **(ruby)** support build revisions for precompiled binaries in
mise.lock by @jdx in [#8900](#8900)
- **(swift)** fall back to Ubuntu 24.04 for unsupported Ubuntu versions
by @jdx in [#8916](#8916)
- **(zsh)** avoid duplicate trust warning after cd by @timothysparg in
[#8898](#8898)
- update flake.lock and add fix for rust-bindgen to default.nix by
@esteve in [#8874](#8874)
- when direnv diff is empty, do not try to parse it by @yaleman in
[#8857](#8857)
- skip trust check for plain .tool-versions in task list by @dportalesr
in [#8876](#8876)

### 🚜 Refactor

- **(go)** rename go_* settings to go.* namespace by @jdbruijn in
[#8598](#8598)

### 📚 Documentation

- **(tasks)** clarify task_config.includes behavior by @risu729 in
[#8905](#8905)

### 🧪 Testing

- **(ci)** run e2e tests inside Docker containers by @jdx in
[#8899](#8899)

### 📦️ Dependency Updates

- bump ubi from 0.8 to 0.9 by @jdx in
[#8906](#8906)
- bump zip from 3 to 8 by @jdx in
[#8908](#8908)
- update lockfile deps (hold back rattler) by @jdx in
[#8909](#8909)
- update bun.lock by @jdx in
[#8913](#8913)

### 📦 Registry

- add turso
([github:tursodatabase/turso-cli](https://github.com/tursodatabase/turso-cli))
by @kenn in [#8884](#8884)
- remove carp test by @jdx in
[#8894](#8894)

### Chore

- **(ci)** add workflow to warn PRs modifying vendored aqua-registry by
@jdx in [#8897](#8897)
- **(ci)** use github.token for draft conversion in auto-draft workflow
by @jdx in [#8903](#8903)
- remove deprecated settings older than 12 months by @jdx in
[#8904](#8904)

### New Contributors

- @dportalesr made their first contribution in
[#8876](#8876)
- @timothysparg made their first contribution in
[#8898](#8898)
- @hehaoqian made their first contribution in
[#8750](#8750)
- @jdbruijn made their first contribution in
[#8598](#8598)
- @cprecioso made their first contribution in
[#8776](#8776)
- @yaleman made their first contribution in
[#8857](#8857)
- @kenn made their first contribution in
[#8884](#8884)
- @fragon10 made their first contribution in
[#8524](#8524)

## 📦 Aqua Registry Updates

#### New Packages (6)

- [`ahkohd/oyo`](https://github.com/ahkohd/oyo)
- [`bellicose100xp/jiq`](https://github.com/bellicose100xp/jiq)
- [`kurama/dealve-tui`](https://github.com/kurama/dealve-tui)
- [`micahkepe/jsongrep`](https://github.com/micahkepe/jsongrep)
- [`textfuel/lazyjira`](https://github.com/textfuel/lazyjira)
- [`ubugeeei/vize`](https://github.com/ubugeeei/vize)

#### Updated Packages (1)

- [`sigstore/cosign`](https://github.com/sigstore/cosign)
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.

1 participant