Skip to content

fix(opencode): ensure standard PATH directories for bash tool on macOS#21347

Open
divitkashyap wants to merge 1 commit intoanomalyco:devfrom
divitkashyap:fix/bash-env-path
Open

fix(opencode): ensure standard PATH directories for bash tool on macOS#21347
divitkashyap wants to merge 1 commit intoanomalyco:devfrom
divitkashyap:fix/bash-env-path

Conversation

@divitkashyap
Copy link
Copy Markdown

@divitkashyap divitkashyap commented Apr 7, 2026

Issue for this PR

Type of change

  • Bug fix

What does this PR do?

On macOS, the agent's bash tool may not have access to standard directories like /opt/homebrew/bin when the parent process has an incomplete PATH. This causes commands like git and gh to fail with env: sh: No such file or directory.
This change prepends standard macOS PATH directories to the shell environment before executing bash commands, ensuring consistency with the user's shell environment.
Modified packages/opencode/src/tool/bash.ts to prepend standard paths (/opt/homebrew/bin, /usr/local/bin, /usr/bin, /bin) on macOS when missing from PATH.

How did you verify your code works?

Logic review — the change ensures standard directories are present in PATH before bash command execution, which is the same location where PATH issues were occurring.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@divitkashyap
Copy link
Copy Markdown
Author

Note on e2e (windows) failures

The 4 failing e2e tests are unrelated to this change:

  1. server-default.spec.ts - Windows popover UI timing out waiting for [data-component="popover-content"]
  2. settings.spec.ts - Windows select dropdown element stability issues
  3. terminal-reconnect.spec.ts / terminal-tabs.spec.ts - Windows terminal state polling failures

These tests are platform-specific to Windows and don't exercise the code changed (bash.ts PATH fix only runs on process.platform === 'darwin').

The failures appear to be pre-existing flaky tests - notice they failed on retry attempts (retry #1, #2) indicating timing/race condition issues rather than regressions.

This change only modifies packages/opencode/src/tool/bash.ts to ensure standard PATH directories (/opt/homebrew/bin, /usr/local/bin, /usr/bin, /bin) are available on macOS before bash command execution.

@rekram1-node could you review? This partially addresses issue #17792.

On macOS, the agent bash tool may lack access to /opt/homebrew/bin,
causing 'git' and 'gh' to fail with 'env: sh: No such file or directory'.

This prepends standard macOS PATH directories before bash execution.

Fixes a partial aspect of anomalyco#17792
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.

[FEATURE]: Unify shell initialization behavior between user shell and agent bash tool

1 participant