Windows TUI copy fails: Executable not found in $PATH: "powershell.exe" (installed via Bun) #7734

Closed
opened 2026-02-16 18:08:05 -05:00 by yindo · 1 comment
Owner

Originally created by @Abdo-Eid on GitHub (Jan 27, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Description

On Windows, copying a selection in the OpenCode TUI fails with:

Executable not found in $PATH: "powershell.exe"

I installed OpenCode via Bun:

bun add -g opencode-ai

PowerShell 7 (pwsh.exe) is installed and is my main shell, but the legacy Windows PowerShell path was removed from PATH. The TUI appears to invoke powershell.exe (likely for Set-Clipboard), so PATH resolution fails even though the file exists on disk.

Why it happens

Many Windows clipboard implementations in CLIs still rely on Windows PowerShell 5.1:

powershell.exe -Command Set-Clipboard ...

If this directory is missing from PATH:

C:\Windows\System32\WindowsPowerShell\v1.0\

then powershell.exe can’t be found, causing the error.

Environment

  • OS: Windows
  • Shell: PowerShell 7 (pwsh)
  • Install: bun add -g opencode-ai
  • Issue: TUI selection copy/clipboard

Checks (commands that worked)

File exists:

Test-Path "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"

PATH contains the directory:

$env:Path -split ';' | Select-String -SimpleMatch "WindowsPowerShell\v1.0"

Verify resolution (important: where is an alias in PowerShell, so use where.exe):

where.exe powershell

Verify Windows PowerShell runs:

powershell -NoProfile -Command '$PSVersionTable.PSVersion'

Expected output shows PowerShell 5.1.x.

Fix

Add back to System PATH:

C:\Windows\System32\WindowsPowerShell\v1.0\

Restart terminal + restart the TUI.

Suggested improvement

On Windows, fallback order could be:

  1. pwsh.exe
  2. powershell.exe
  3. clip.exe

This avoids clipboard failures on machines that only expose PowerShell 7.

Plugins

No response

OpenCode version

1.1.36

Steps to reproduce

Steps to Reproduce

  1. Use Windows with PowerShell 7 as primary shell
    Install PowerShell 7 and remove the legacy Windows PowerShell path from PATH:

    C:\Windows\System32\WindowsPowerShell\v1.0\
    
  2. Install OpenCode using Bun

    bun add -g opencode-ai
    
  3. Open a new PowerShell terminal

  4. Run OpenCode

    opencode
    
  5. Inside the TUI, select text and trigger copy

  6. Observe error

    Executable not found in $PATH: "powershell.exe"
    

Root condition required

The issue occurs when:

  • powershell.exe exists on disk
  • but its directory is missing from PATH
  • and the TUI attempts to use it for clipboard operations

Screenshot and/or share link

Image

Operating System

Windows 11

Terminal

Windows Terminal

Originally created by @Abdo-Eid on GitHub (Jan 27, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description ### Description On Windows, copying a selection in the OpenCode TUI fails with: ``` Executable not found in $PATH: "powershell.exe" ``` I installed OpenCode via Bun: ``` bun add -g opencode-ai ``` PowerShell 7 (`pwsh.exe`) is installed and is my main shell, but the legacy Windows PowerShell path was removed from PATH. The TUI appears to invoke `powershell.exe` (likely for `Set-Clipboard`), so PATH resolution fails even though the file exists on disk. ### Why it happens Many Windows clipboard implementations in CLIs still rely on **Windows PowerShell 5.1**: ``` powershell.exe -Command Set-Clipboard ... ``` If this directory is missing from PATH: ``` C:\Windows\System32\WindowsPowerShell\v1.0\ ``` then `powershell.exe` can’t be found, causing the error. ### Environment * OS: Windows * Shell: PowerShell 7 (`pwsh`) * Install: `bun add -g opencode-ai` * Issue: TUI selection copy/clipboard ### Checks (commands that worked) File exists: ```powershell Test-Path "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" ``` PATH contains the directory: ```powershell $env:Path -split ';' | Select-String -SimpleMatch "WindowsPowerShell\v1.0" ``` Verify resolution (important: `where` is an alias in PowerShell, so use `where.exe`): ```powershell where.exe powershell ``` Verify Windows PowerShell runs: ```powershell powershell -NoProfile -Command '$PSVersionTable.PSVersion' ``` Expected output shows PowerShell **5.1.x**. ### Fix Add back to **System PATH**: ``` C:\Windows\System32\WindowsPowerShell\v1.0\ ``` Restart terminal + restart the TUI. ### Suggested improvement On Windows, fallback order could be: 1. `pwsh.exe` 2. `powershell.exe` 3. `clip.exe` This avoids clipboard failures on machines that only expose PowerShell 7. ### Plugins _No response_ ### OpenCode version 1.1.36 ### Steps to reproduce ### Steps to Reproduce 1. **Use Windows with PowerShell 7 as primary shell** Install PowerShell 7 and remove the legacy Windows PowerShell path from PATH: ``` C:\Windows\System32\WindowsPowerShell\v1.0\ ``` 2. **Install OpenCode using Bun** ``` bun add -g opencode-ai ``` 3. **Open a new PowerShell terminal** 4. **Run OpenCode** ``` opencode ``` 5. **Inside the TUI, select text and trigger copy** 6. **Observe error** ``` Executable not found in $PATH: "powershell.exe" ``` ### Root condition required The issue occurs when: * `powershell.exe` exists on disk * but its directory is missing from PATH * and the TUI attempts to use it for clipboard operations ### Screenshot and/or share link <img width="526" height="216" alt="Image" src="https://github.com/user-attachments/assets/216a34d2-9bb6-4352-aa6d-7ec354593652" /> ### Operating System Windows 11 ### Terminal Windows Terminal
yindo added the windowsopentuibug labels 2026-02-16 18:08:05 -05:00
yindo closed this issue 2026-02-16 18:08:05 -05:00
Author
Owner

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

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

  • #9999: Clipboard functionality fails in WSL environment due to missing Windows executable paths (related PowerShell PATH issue)
  • #5879: Clipboard copy in WSL (Windows clipboard access from WSL)
  • #10128: [WSL][tmux] opencode cannot copy text in WSL tmux (similar clipboard functionality issue on Windows)

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 27, 2026): This issue might be a duplicate of existing issues. Please check: - #9999: Clipboard functionality fails in WSL environment due to missing Windows executable paths (related PowerShell PATH issue) - #5879: Clipboard copy in WSL (Windows clipboard access from WSL) - #10128: [WSL][tmux] opencode cannot copy text in WSL tmux (similar clipboard functionality issue on Windows) Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7734