Skip to content

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

Closed
divitkashyap wants to merge 2 commits into
anomalyco:devfrom
divitkashyap:fix/bash-env-path
Closed

fix(opencode): ensure standard PATH directories for bash tool on macOS#21347
divitkashyap wants to merge 2 commits into
anomalyco: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

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
@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.

@divitkashyap
Copy link
Copy Markdown
Author

👋 Bumping this PR for review. This fix ensures standard PATH directories for bash tool on macOS. Changes in packages/opencode/src/tool/bash.ts

@rekram1-node
Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

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

2 participants