Skip to content

fix: select the native package manager per Linux distribution#4773

Open
ddeskov-limechain wants to merge 2 commits into
hiero-ledger:mainfrom
ddeskov-limechain:bug-brew-install-hiero-ledger/tools/solo-fails-on-Fedora-Linux
Open

fix: select the native package manager per Linux distribution#4773
ddeskov-limechain wants to merge 2 commits into
hiero-ledger:mainfrom
ddeskov-limechain:bug-brew-install-hiero-ledger/tools/solo-fails-on-Fedora-Linux

Conversation

@ddeskov-limechain

Copy link
Copy Markdown

Description

This pull request makes Solo's Linux install flow distribution-aware instead of assuming apt-get + Homebrew on every Linux host. Previously solo init / one-shot on Linux hard-coded apt-get and bootstrapped linuxbrew to run brew install podman — on Fedora (and any non-Debian distro) this failed immediately (apt-get absent) and the linuxbrew bootstrap required a C compiler ("Install Clang or run brew install gcc"), which is the exact failure reported in #4676.

This pull request changes the following:

  • Detects the Linux distribution from /etc/os-release (ID / ID_LIKE) and routes to the correct native package manager.
  • Adds a shared LinuxPackageManager base plus dnf, zypper, pacman, and apk managers alongside the existing apt-get one; refactors apt-get onto the base and makes every install/remove/update/upgrade command non-interactive (e.g. -y, --noconfirm, --non-interactive).
  • OsPackageManager now resolves the manager per-distro via /etc/os-release, with a binary-probe fallback (FALLBACK_PROBE_ORDER), and throws a clear UnsupportedLinuxDistributionSoloError (SOLO-5074) when nothing matches.
  • Lifts the sudo-callback setters onto the PackageManager interface, removing the getPackageManager() as AptGetPackageManager down-cast in cluster-task-manager.ts.
  • Installs git, iptables, and podman on Linux via the native package manager and drops the linuxbrew bootstrap on Linux — removing the C-compiler/Homebrew dependency. macOS (VM-mode podman binary download) is unchanged.
  • Removes now-dead brewPackageManager / osPackageManager injections from init.
  • Adds unit tests for distribution detection and per-manager command building.

Behavior change to be aware of (not a contract break): on Linux the mechanism that installs podman changes from linuxbrew to the native package manager. The end state (podman installed, cluster created) is unchanged, and on the distros tested the native podman is current (see versions in the test table). On very old Ubuntu LTS the apt-provided podman could be older than what linuxbrew shipped — called out under "not tested" below.

Related Issues

Pull request (PR) checklist

  • This PR added tests (unit, integration, and/or end-to-end)
  • This PR updated documentation — no in-repo docs change required; the runtime now emits a clear UnsupportedLinuxDistributionSoloError for unsupported distros, and the original brew install formula concern lives in hiero-ledger/homebrew-tools (tracked by fix: add recursive option to mkdir #215)
  • This PR added no TODOs or commented out code
  • This PR has no breaking changes (no CLI flag/output/contract changes; Linux install mechanism change documented above)
  • Any technical debt has been documented as a separate issue and linked to this PR — N/A, none introduced
  • Any package.json changes have been explained to and approved by a repository manager — N/A, no package.json changes
  • All related issues have been linked to this PR
  • All changes in this PR are included in the description
  • When this PR merges the commits will be squashed and the title will be used as the commit message, the 'commit message guidelines' below have been followed

Testing

  • This PR added unit tests
  • This PR added integration/end-to-end tests
  • These changes required manual testing that is documented below
  • Anything not tested is documented

The following manual testing was done:

1. Unit tests (real detection + command-builder code) — 33 passing, 0 failing

npx mocha 'test/unit/core/package-managers/os-package-manager.test.ts' 'test/unit/core/package-managers/linux-package-managers.test.ts'
  • Detection: fedora→dnf, ubuntu→apt-get, debian→apt-get, opensuse-leap→zypper, arch→pacman, alpine→apk, rocky matched via ID_LIKEdnf, and an unsupported distro throws UnsupportedLinuxDistributionSoloError.
  • Command builders: every manager asserts the exact string emitted for install / remove / update / upgrade, and that the availability check (--version) runs without sudo.
  • The existing init and cluster-task-manager unit tests still pass with the slimmed constructors.

2. Static checks

  • npx tsc — clean (no type errors).
  • npx eslint on all changed files — 0 errors.
  • npx dpdm … circular:1 — no circular dependencies introduced.

3. Cross-platform verification on real distributions (Docker)

For each target distro I ran an ephemeral container (docker run --rm --pull=missing -v verify.sh:/verify.sh:ro <image> sh /verify.sh). The in-container script:

  1. parses the real /etc/os-release (ID / ID_LIKE),
  2. selects the package manager using the same mapping + binary-probe fallback as OsPackageManager,
  3. confirms apt-get is absent on non-Debian distros (proving the old "apt-get everywhere" path would have failed there),
  4. confirms no C compiler is present or needed,
  5. runs the exact command Solo emits — e.g. dnf install -y git iptables podman — and
  6. verifies git, iptables, and podman are installed and prints their versions.
Distro Image Expected → selected manager apt-get absent (old bug) Install RC git / iptables / podman podman version Result
Fedora fedora:latest dnf → dnf yes 0 all present 5.8.3 PASS
Ubuntu ubuntu:latest apt-get → apt-get n/a (Debian) 0 all present 5.7.0 PASS
openSUSE Leap opensuse/leap:latest zypper → zypper yes 0 all present 5.4.2 PASS
Alpine alpine:latest apk → apk yes 0 all present 5.8.3 PASS
Arch menci/archlinuxarm:base (arm64) pacman → pacman yes 0 all present 5.8.3 PASS
  • All five select the correct native package manager from their real /etc/os-release, install git + iptables + podman natively, and report no C compiler present or required — the gcc/clang + Homebrew failure from brew install hiero-ledger/tools/solo fails on Fedora Linux (no bottle, source build also fails) #4676 is gone.
  • Fedora — the exact OS in the bug report — passes cleanly.
  • The Arch image reports ID=archarm (Arch Linux ARM), which is not in the os-release map; Solo still correctly selected pacman via the stage-2 binary-probe fallback, exercising that path on a real system.
  • Arch was first attempted on archlinux:latest under x86-64 qemu emulation (Apple-Silicon host) and failed there due to pacman 6.1's internal seccomp sandbox being incompatible with qemu-user emulation — an environment artifact, not a Solo defect. Re-running on an arm64-native image gave a genuine PASS. The arm64 Arch community image needed base prep (pacman-key --init/--populate, plus pacman -Syu to reconcile a stale gcc-libslibgcc/libstdc++ split); this prep does not alter the command Solo emits.

The following was not tested:

  • The full rootful solo init end-to-end flow (kind cluster creation, sudo elevation, rootful podman) on a real non-Ubuntu Linux host — the Docker matrix validates distro detection and the exact native package-install commands, but not the surrounding Listr task orchestration or the sudo wrapper (containers run as root).
  • Podman version provided by apt on older Ubuntu LTS releases — on the tested ubuntu:latest it is current (5.7.0), but older LTS apt repos may ship an older podman than linuxbrew did.
  • Windows (WSL2) — unchanged; still routes to apt-get.
Commit message guidelines We use 'Conventional Commits' to ensure that our commit messages are easy to read, follow a consistent format, and for automated release note generation. Please follow the guidelines below when writing your commit messages:
  1. BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type. NOTE: currently breaking changes will only bump the MAJOR version.
  2. The title is prefixed with one of the following:
Prefix Description Semantic Version Update Captured in Release Notes
feat: a new feature MINOR Yes
fix: a bug fix PATCH Yes
perf: performance PATCH Yes
refactor: code change that isn't feature or fix none No
test: adding missing tests none No
docs: changes to documentation none Yes
build: changes to build process none No
ci: changes to CI configuration none No
style: formatting, missing semi-colons, etc none No
chore: updating grunt tasks etc; no production code change none No

Signed-off-by: Dian Deskov <dian.deskov@limechain.tech>
@trunk-io

trunk-io Bot commented Jun 23, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@ddeskov-limechain ddeskov-limechain self-assigned this Jun 23, 2026
@jeromy-cannon jeromy-cannon added the P2-⏭️💎 Next Milestone & Goals label Jun 23, 2026
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@          Coverage Diff           @@
##             main   #4773   +/-   ##
======================================
  Coverage        ?       0           
======================================
  Files           ?       0           
  Lines           ?       0           
  Branches        ?       0           
======================================
  Hits            ?       0           
  Misses          ?       0           
  Partials        ?       0           

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2-⏭️💎 Next Milestone & Goals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

brew install hiero-ledger/tools/solo fails on Fedora Linux (no bottle, source build also fails)

2 participants