Skip to content

fix(github): improve asset detection for distro-specific and Swift artifacts#7347

Merged
jdx merged 1 commit into
mainfrom
fix/github-backend-asset-detection
Dec 17, 2025
Merged

fix(github): improve asset detection for distro-specific and Swift artifacts#7347
jdx merged 1 commit into
mainfrom
fix/github-backend-asset-detection

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Dec 17, 2025

Summary

  • Add Linux distro names (ubuntu, debian, fedora, centos, rhel, alpine, arch) to OS detection pattern so distro-specific releases are correctly identified
  • Increase wrong OS penalty from -50 to -100 so it outweighs architecture match bonus (+50), preventing cross-platform mismatches
  • Add penalty for .artifactbundle.zip files (Swift Package Manager bundles) which are not suitable for direct tool installation

Fixes #7345

Problem

The GitHub backend was selecting wrong release assets for Sourcery on macOS:

  1. Downloading sourcery-X.Y.Z.artifactbundle.zip (Swift Package Manager bundle) instead of sourcery-X.Y.Z.zip (actual macOS binary)
  2. Downloading Ubuntu/Linux archives on macOS systems (e.g., sourcery-X.Y.Z-ubuntu-jammy-22.04.3-lts-aarch64.tar.xz)

Root cause: The asset scoring algorithm had two issues:

  1. "ubuntu" wasn't recognized as a Linux distribution, so Ubuntu assets weren't penalized for wrong OS on macOS
  2. The wrong OS penalty (-50) was exactly cancelled out by the architecture match bonus (+50), causing ties

Test plan

  • Added unit test test_sourcery_macos_assets that verifies macOS picks plain .zip over artifactbundle and ubuntu
  • Added unit test test_artifactbundle_penalty that verifies .artifactbundle.zip scores lower than plain .zip
  • Added unit test test_ubuntu_detected_as_linux that verifies ubuntu is detected as Linux
  • All existing asset_detector tests pass
  • All 381 unit tests pass

🤖 Generated with Claude Code


Note

Recognizes Linux distro names, increases wrong-OS penalty, penalizes .artifactbundle files, and adds tests to validate correct asset selection.

  • Backend: asset detection (src/backend/asset_detector.rs)
    • Expand Linux OS regex to include common distros: ubuntu, debian, fedora, centos, rhel, alpine, arch.
    • Increase wrong-OS penalty from -50 to -100 so it outweighs arch match bonus.
    • Add build penalty for Swift Package Manager bundles: .artifactbundle (-30).
  • Tests
    • Adjust assertion to ensure non-target OS assets score lower than correct ones.
    • Add tests: test_sourcery_macos_assets, test_artifactbundle_penalty, test_ubuntu_detected_as_linux.

Written by Cursor Bugbot for commit acc48cc. This will update automatically on new commits. Configure here.

…tifacts

- Add Linux distro names (ubuntu, debian, fedora, centos, rhel, alpine, arch)
  to OS detection pattern so distro-specific releases are correctly identified
- Increase wrong OS penalty from -50 to -100 so it outweighs architecture
  match bonus (+50), preventing cross-platform mismatches
- Add penalty for .artifactbundle.zip files (Swift Package Manager bundles)
  which are not suitable for direct tool installation

Fixes krzysztofzablocki/Sourcery installation on macOS where:
- Ubuntu tarballs were incorrectly selected due to matching architecture
- Swift artifact bundles were preferred over plain release archives

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings December 17, 2025 13:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes asset selection logic in the GitHub backend to properly identify and score Linux distribution-specific releases and Swift Package Manager artifacts. The changes prevent mise from downloading incorrect release assets for tools like Sourcery on macOS.

Key Changes:

  • Extended OS detection regex to recognize common Linux distro names (ubuntu, debian, fedora, etc.)
  • Increased wrong OS penalty from -50 to -100 to prevent architecture matches from overriding OS mismatches
  • Added penalty for .artifactbundle.zip files which are Swift Package Manager bundles unsuitable for direct installation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

AssetOs::Linux,
Regex::new(r"(?i)(?:\b|_)linux(?:\b|_|32|64)").unwrap(),
// Include common Linux distro names that may appear in release asset names
Regex::new(r"(?i)(?:\b|_)(?:linux|ubuntu|debian|fedora|centos|rhel|alpine|arch)(?:\b|_|32|64|-)")
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The regex pattern allows a hyphen - as a terminating character but not as a word boundary at the start. This creates an asymmetry that could cause issues with asset names like my-ubuntu-tool where the leading hyphen before 'ubuntu' won't match the (?:\b|_) prefix. Consider adding - to the prefix alternatives: (?:\b|_|-) to match the suffix pattern.

Copilot uses AI. Check for mistakes.
Comment on lines +500 to +501
macos_score < gnu_score,
"macOS assets should score lower than Linux assets when using a Linux picker"
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The test assertion message references 'Linux picker' but doesn't verify the actual score relationship is due to the wrong OS penalty. Consider adding an assertion that verifies macos_score is negative (indicating wrong OS penalty was applied) to more explicitly test the penalty behavior.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.10 x -- echo 19.3 ± 0.2 18.8 21.5 1.00
mise x -- echo 19.5 ± 1.0 19.0 40.2 1.01 ± 0.05

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.10 env 18.7 ± 0.5 18.1 24.4 1.00
mise env 18.9 ± 0.2 18.3 19.7 1.01 ± 0.03

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.10 hook-env 18.8 ± 0.2 18.4 20.5 1.00
mise hook-env 19.1 ± 0.4 18.5 24.6 1.02 ± 0.02

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.10 ls 16.4 ± 0.2 16.0 17.5 1.00
mise ls 16.7 ± 0.6 16.1 22.8 1.02 ± 0.04

xtasks/test/perf

Command mise-2025.12.10 mise Variance
install (cached) 107ms 108ms +0%
ls (cached) 64ms 65ms -1%
bin-paths (cached) 70ms 71ms -1%
task-ls (cached) 275ms 274ms +0%

@jdx jdx merged commit 1b02415 into main Dec 17, 2025
30 checks passed
@jdx jdx deleted the fix/github-backend-asset-detection branch December 17, 2025 13:59
jdx pushed a commit that referenced this pull request Dec 18, 2025
### 🚀 Features

- **(alias)** rename alias to tool-alias, add shell-alias command by
@jdx in [#7357](#7357)
- **(upgrade)** display summary of upgraded tools by @jdx in
[#7372](#7372)
- **(vfox)** embed vfox plugin Lua code in binary by @jdx in
[#7369](#7369)

### 🐛 Bug Fixes

- **(aqua)** add start_operations for progress reporting by @jdx in
[#7354](#7354)
- **(github)** improve asset detection for distro-specific and Swift
artifacts by @jdx in [#7347](#7347)
- **(github)** clean up static_helpers.rs and fix archive bin= option by
@jdx in [#7366](#7366)
- **(http)** add start_operations for progress reporting by @jdx in
[#7355](#7355)
- **(lockfile)** place lockfile alongside config file by @jdx in
[#7360](#7360)
- **(progress)** add start_operations to core plugins by @jdx in
[#7351](#7351)
- **(ruby-install)** Use ruby_install_bin to update by @calebhearth in
[#7350](#7350)
- **(rust)** add release_url for rust versions by @jdx in
[#7373](#7373)
- **(schema)** add `tool_alias`, mark `alias` as deprecated by @SKalt in
[#7358](#7358)
- **(toolset)** filter tools by OS in list_current_versions by @jdx in
[#7356](#7356)
- **(ubi)** only show deprecation warning during installation by @jdx in
[#7380](#7380)
- **(ui)** remove noisy "record size" message during install by @jdx in
[#7381](#7381)
- update mise-versions URL to use /tools/ prefix by @jdx in
[#7378](#7378)

### 🚜 Refactor

- **(backend)** unified AssetMatcher with checksum fetching by @jdx in
[#7370](#7370)
- **(backend)** deprecate ubi backend in favor of github by @jdx in
[#7374](#7374)
- **(toolset)** decompose mod.rs into smaller modules by @jdx in
[#7371](#7371)

### 🧪 Testing

- **(e2e)** fix and rename ubi and vfox_embedded_override tests by @jdx
in
[052ea40](052ea40)

### 📦 Registry

- add vfox-gcloud backend for gcloud by @jdx in
[#7349](#7349)
- convert amplify to use github backend by @jdx in
[#7365](#7365)
- add github backend for djinni tool by @jdx in
[#7363](#7363)
- switch glab to native gitlab backend by @jdx in
[#7364](#7364)
- add s5cmd by @jdx in [#7376](#7376)

### Chore

- **(registry)** disable flaky tests for gitu and ktlint by @jdx in
[64151cb](64151cb)
- resolve clippy warnings and add stricter CI check by @jdx in
[#7367](#7367)
- suppress dead_code warnings in asset_matcher module by @jdx in
[#7377](#7377)

### New Contributors

- @calebhearth made their first contribution in
[#7350](#7350)
jekis913 added a commit to jekis913/mise that referenced this pull request Dec 18, 2025
* upstream/main:
  fix(lockfile): place lockfile alongside config file (jdx#7360)
  feat(alias): rename alias to tool-alias, add shell-alias command (jdx#7357)
  fix(aqua): add start_operations for progress reporting (jdx#7354)
  fix(schema): add `tool_alias`, mark `alias` as deprecated (jdx#7358)
  fix(progress): add start_operations to core plugins (jdx#7351)
  fix(toolset): filter tools by OS in list_current_versions (jdx#7356)
  registry: add vfox-gcloud backend for gcloud (jdx#7349)
  fix(github): improve asset detection for distro-specific and Swift artifacts (jdx#7347)
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.

2 participants