Skip to content

[Windows] "Open in → PowerShell" fails with CommandNotFoundException (open-path runs the directory as a command) #40277

Closed as not planned

Description

@zk-boop

Description

Clicking "Open in → PowerShell" in the session header dropdown of OpenCode Desktop on Windows fails with an error toast:

Error invoking remote method 'open-path': Error: Command failed:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
D:\path\to\project
D:\path\to\project : The term 'D:\path\to\project' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (CommandNotFoundException)

Root cause (from reading the packaged code): the renderer's Windows "Open in" menu passes openWith: "powershell", which calls platform.openPath(directory, "powershell"). The main-process handler then runs:

execFile("powershell", [path]) // = powershell.exe D:\path\to\project

PowerShell treats the positional argument as a script/command to execute, not a directory to open, so it fails with CommandNotFoundException. This affects any shell (verified with both Windows PowerShell 5.1 and PowerShell 7 / pwsh), so it is broken by design of the open-path handler, not environment-specific.

Expected: "Open in → PowerShell" should open a PowerShell session in the project directory, e.g. spawn powershell/pwsh with -NoExit -WorkingDirectory , or reuse the node-pty shell spawn the app already uses for its built-in terminal panel (which works correctly).

Plugins

None

OpenCode version

OpenCode Desktop 1.18.11 (bundled opencode sidecar)

Steps to reproduce

  1. Open OpenCode Desktop on Windows and open any project folder
  2. In the session header, click the "Open in" dropdown
  3. Select "PowerShell"
  4. An error toast appears: CommandNotFoundException - the project directory is executed as a command

Screenshot and/or share link

Image

Operating System

Windows 11

Terminal

OpenCode Desktop built-in terminal panel / Windows Terminal

Activity

  1. github-actions commented on Aug 3, 2026

    @github-actions
    Contributor

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

    These issues describe the same root cause and symptoms. Please review them and consider adding any additional context there instead.

  2. hokonoko commented on Sep 2, 2026

    @hokonoko

    Opened a PR for this: #46712 — verified on Windows 11 with project paths containing spaces, single quotes, % chars, and non-ASCII characters.

  3. HigeMaguro commented on Sep 7, 2026

    @HigeMaguro

    Still reproduces on OpenCode Desktop 1.18.29 / Windows 11 (PowerShell 5.1)

    Environment:

    • OpenCode Desktop: 1.18.29
    • OS: Windows 11 x64 (build 26100)
    • Shell: Windows PowerShell 5.1 (5.1.26100.9168) — also fails when selecting PowerShell 7 (pwsh)

    Same Error invoking remote method 'open-path' dialog when choosing "Open in → PowerShell" from the top-right dropdown. The invoked command matches the reported root cause — the project path is passed as a positional argument:

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\DATA\src\opencode
    

    Additional observation: on a Japanese-locale Windows, the error message inside the dialog is garbled (mojibake) — the localized CommandNotFoundException text is rendered with wrong encoding, which may be worth handling in the fix for readability.

    Hope the PR #46712 lands soon. Happy to test a nightly build if needed.

  4. HigeMaguro commented on Sep 22, 2026

    @HigeMaguro

    Still reproducible on a fresh install. Same root cause confirmed.

    Environment

    • OpenCode Desktop: 1.18.32 (latest release as of 2026-09-22)
    • OS: Windows 11 (win32, PowerShell 5.1)

    Reproduced behavior

    open-path runs:

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe D:\OBSIDIANDATA\developer
    

    and fails with CommandNotFoundException (CategoryInfo: ObjectNotFound), because the working directory is passed as a positional argument and PowerShell executes it as a command.

    Confirmed at the code level - in the packaged resources\app.asar / out\main\index.js (v1.18.32):

    ipcMain.handle("open-path", async (_event, path, app2) => {
      if (!app2) return shell.openPath(path);
      await new Promise((resolve2, reject) => {
        const [cmd, args] = process.platform === "darwin"
          ? ["open", ["-a", app2, path]]
          : [app2, [path]];   // <- path passed as the sole argv[1]
        execFile(cmd, args, (err) => err ? reject(err) : resolve2());
      });
    });

    The renderer's Windows menu entry is openWith: "powershell", so this resolves to execFile("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", [path]).

    I verified the exact failure by running the same command directly:

    powershell.exe D:\OBSIDIANDATA\developer
    + CategoryInfo : ObjectNotFound: (D:\OBSIDIANDATA\developer:String) [], CommandNotFoundException
    

    This is broken on Windows by design of the open-path handler, independent of shell version (affects both Windows PowerShell 5.1 and pwsh 7).

    Note: A fix PR is already open and awaiting review/merge: #46712 (cmd /d /c start + -EncodedCommand/Set-Location -LiteralPath). Happy to retest once it lands.

  5. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions