Skip to content

fix: resolve bash not found on minimal OS installs#12266

Open
jakub961241 wants to merge 1 commit into1Panel-dev:dev-v2from
jakub961241:fix/bash-path-lookup-12257
Open

fix: resolve bash not found on minimal OS installs#12266
jakub961241 wants to merge 1 commit into1Panel-dev:dev-v2from
jakub961241:fix/bash-path-lookup-12257

Conversation

@jakub961241
Copy link

Summary

Fixes #12257 - Snapshot restore fails on AlmaLinux 10 with:

exec: "bash": executable file not found in $PATH

Root Cause

exec.Command("bash", ...) is used throughout the codebase, but on minimal OS installs (AlmaLinux, some RHEL-based), bash is not in the default $PATH even though it exists at /bin/bash or /usr/bin/bash.

Fix

Added BashPath() helper function to both core/utils/cmd and agent/utils/cmd packages:

  1. First tries exec.LookPath("bash") (standard PATH lookup)
  2. Falls back to checking /bin/bash, /usr/bin/bash, /usr/local/bin/bash
  3. Result is cached with sync.Once for performance

Replaced all exec.Command("bash", ...) calls with exec.Command(BashPath(), ...) in:

  • core/utils/cmd/cmd.go
  • core/utils/cmd/cmdx.go
  • core/utils/terminal/local_cmd.go
  • core/i18n/i18n.go
  • agent/utils/cmd/cmd.go
  • agent/utils/cmd/cmdx.go
fix: Resolve "bash: executable file not found in $PATH" error on minimal OS installs like AlmaLinux (#12257)

On minimal OS installations (e.g., AlmaLinux 10), bash may not be in
the default $PATH, causing snapshot restore and other operations to
fail with: exec: "bash": executable file not found in $PATH

Add BashPath() helper that uses exec.LookPath first, then falls back
to checking /bin/bash, /usr/bin/bash, /usr/local/bin/bash. Applied to
both core and agent cmd packages and all callers.

Fixes 1Panel-dev#12257
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 21, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ssongliu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] cmd.Start() failed with 'exec: "bash": executable file not found in $PATH'

1 participant