bash tool: external_directory prompt skipped when realpath is missing #7762

Open
opened 2026-02-16 18:08:09 -05:00 by yindo · 2 comments
Owner

Originally created by @MaxMiksa on GitHub (Jan 27, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

The bash tool tries to detect when a command targets paths outside the project directory to request external_directory permission. Current path resolution relies on an external realpath binary, which is not reliably available on Windows / some environments, so the external directory prompt can be skipped.

Plugins

N/A

OpenCode version

dev (local checkout @ 213c0e18a, package packages/opencode v1.1.36)

Steps to reproduce

  1. Run in an environment where realpath is not present on PATH (common on Windows)
  2. Execute a bash tool command that leaves the project directory (e.g. cd ..)
  3. Observe whether an external_directory permission request is issued

Operating System

Windows 11

Terminal

Windows Terminal

Expected

Even without realpath, Opencode should still resolve candidate target paths (e.g. via path.resolve) and request external_directory permission when leaving Instance.directory.

Actual

Path resolution fails silently when realpath is missing, resulting in no external_directory permission request for commands like cd .. / file operations targeting outside directories.

Originally created by @MaxMiksa on GitHub (Jan 27, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description The `bash` tool tries to detect when a command targets paths outside the project directory to request `external_directory` permission. Current path resolution relies on an external `realpath` binary, which is not reliably available on Windows / some environments, so the external directory prompt can be skipped. ### Plugins N/A ### OpenCode version `dev` (local checkout @ `213c0e18a`, package `packages/opencode` v1.1.36) ### Steps to reproduce 1. Run in an environment where `realpath` is not present on PATH (common on Windows) 2. Execute a `bash` tool command that leaves the project directory (e.g. `cd ..`) 3. Observe whether an `external_directory` permission request is issued ### Operating System Windows 11 ### Terminal Windows Terminal ### Expected Even without `realpath`, Opencode should still resolve candidate target paths (e.g. via `path.resolve`) and request `external_directory` permission when leaving `Instance.directory`. ### Actual Path resolution fails silently when `realpath` is missing, resulting in no `external_directory` permission request for commands like `cd ..` / file operations targeting outside directories.
yindo added the windows label 2026-02-16 18:08:09 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 27, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #10871: Windows: Git Bash auto-detection derives invalid bash.exe path

Both issues involve bash tool path resolution issues on Windows and missing external dependencies/binaries. While #10871 focuses on Git Bash auto-detection, #10872 addresses a related path resolution problem when realpath is unavailable. They may share root causes around Windows path handling in the bash tool.

Feel free to ignore if your specific case differs.

@github-actions[bot] commented on GitHub (Jan 27, 2026): This issue might be a duplicate of existing issues. Please check: - #10871: Windows: Git Bash auto-detection derives invalid bash.exe path Both issues involve bash tool path resolution issues on Windows and missing external dependencies/binaries. While #10871 focuses on Git Bash auto-detection, #10872 addresses a related path resolution problem when `realpath` is unavailable. They may share root causes around Windows path handling in the bash tool. Feel free to ignore if your specific case differs.
Author
Owner

@MaxMiksa commented on GitHub (Jan 27, 2026):

Thanks! Related to Windows bash/tooling, but this one is distinct: bash tool external-directory detection currently relies on an external realpath binary. In environments where realpath isn’t available (common on Windows), the external_directory prompt can be skipped.

PR #10874 removes the external dependency by using internal path.resolve + fs.realpath fallback and adds a regression test.

@MaxMiksa commented on GitHub (Jan 27, 2026): Thanks! Related to Windows bash/tooling, but this one is distinct: `bash` tool external-directory detection currently relies on an external `realpath` binary. In environments where `realpath` isn’t available (common on Windows), the `external_directory` prompt can be skipped. PR #10874 removes the external dependency by using internal `path.resolve` + `fs.realpath` fallback and adds a regression test.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7762