GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): keep multi-line commands intact for Store PowerShell 7 by Hona · Pull Request #62522 · anomalyco/opencode

Conversation

@Hona

@Hona Hona commented Nov 7, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

On Windows with PowerShell 7 installed from the Microsoft Store, the shell tool drops every line of a command after the first one, and still reports exit=0. A plugin that prepends a setup line, such as opencode-windows-encoding, makes every result empty.

  • Cause: since fix(core): find Microsoft Store PowerShell 7 on Windows #61952 the shell resolver can return the Store app execution alias (%LOCALAPPDATA%\Microsoft\WindowsApps\...\pwsh.exe). stat rejects the alias with EACCES, so cross-spawn cannot find it and starts it through cmd.exe /d /s /c. cmd.exe ends the command line at the first newline.
  • Fix: before cross-spawn runs, the spawner reads the link (fs.readLink) of an absolute Windows command and launches the target, the packaged pwsh.exe. The resolver still returns the alias. The target is read on every spawn, so a Store update that moves the package (service: cached Store pwsh path goes stale after package update #56381) does not leave a stale path.
flowchart LR
  A["WindowsApps\…\pwsh.exe (alias)"] --> B{spawner}
  B -- "before: cross-spawn cannot stat it" --> C["cmd.exe /d /s /c"] --> D["line 1 only"]
  B -- "after: readLink" --> E["Program Files\WindowsApps\…_7.6.9.0\pwsh.exe"] --> F["all lines"]
Loading

Real opencode serve binaries with "shell": "pwsh", on a machine with only Store PowerShell 7.6.9. Both builds come from the same dev commit; only this change differs.

Command (session shell API) Before After
pwd ✅ path ✅ path
UTF-8 setup line \n pwd (what the plugin sends) ❌ exit=0 size=0 ✅ path
echo one \n echo two ❌ one ✅ one two
parent process of pwsh cmd opencode
  • Test: cross-spawn-spawner.test.ts runs a two-line command through the borrowed Store pwsh.exe alias and expects both lines. Without the fix it receives only one. It is skipped where Store PowerShell 7 is not installed, as the tests from fix(core): find Microsoft Store PowerShell 7 on Windows #61952 are.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" font-family="ui-monospace, monospace" font-size="11">
  <style>
    .old { animation: old 4s infinite; }
    .new { animation: new 4s infinite; }
    @keyframes old { 0%, 40% { opacity: .9 } 50%, 100% { opacity: .15 } }
    @keyframes new { 0%, 40% { opacity: .15 } 50%, 100% { opacity: .9 } }
    @media (prefers-reduced-motion: reduce) { .old, .new { animation: none } .old { opacity: .15 } .new { opacity: .9 } }
  </style>
  <rect x="0.5" y="0.5" width="239" height="71" stroke="currentColor" stroke-opacity=".3"/>
  <text x="12" y="22" fill="currentColor" opacity=".6">echo one; echo two</text>
  <g class="old"><text x="12" y="42" fill="currentColor">one</text><text x="12" y="58" fill="currentColor" opacity=".4">(lost)</text></g>
  <path d="M100 46 h28 m-6 -5 l6 5 l-6 5" stroke="currentColor" stroke-opacity=".5"/>
  <g class="new"><text x="140" y="42" fill="currentColor">one</text><text x="140" y="58" fill="currentColor">two</text></g>
</svg>

Fixes #62512


Added by the opencode bot (AI-generated).

Related: #62501

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
fix(core): keep multi-line commands intact for Store PowerShell 7
6500c90
Copilot AI balanced review requested due to automatic review settings November 7, 2026 05:29
Copilot AI reviewed Nov 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
Hona enabled auto-merge (squash) November 7, 2026 05:30
opencodejr[bot]
opencodejr Bot reviewed Nov 7, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't run this end to end: it needs Windows with Store-only PowerShell 7, and the sandbox is Linux. From reading the code, the fix matches the cause described in #62512. Launching the link target directly means cross-spawn no longer falls back to cmd.exe /d /s /c, so commands keep every line. Reading the target on each spawn also avoids the stale-path problem from #56381. The spawner tests pass here, with the new test skipped as expected. typecheck:tsc passes for packages/util and packages/core.

Public API: unchanged.

One concern: on Windows the new code follows every symlinked absolute command, not only app execution aliases (see the inline comment).

Related: #62501

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/util/src/cross-spawn-spawner.ts
// reparse point that stat rejects with EACCES. cross-spawn then cannot find it and runs it through
// `cmd.exe /d /s /c`, which drops everything after the first newline of the command line. Launch the target of
// the link instead, read on every spawn because a Store update moves it.
const executable = (file: string) => {

@opencodejr opencodejr Bot Nov 7, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows this follows any symlinked absolute command, not only app execution aliases. A regular symlink already stats fine, so cross-spawn never fell back to cmd.exe for it. Now it gets launched under its target's name. That changes behaviour for multi-call binaries that pick their behaviour from the name they're started with, such as busybox-w32 applet symlinks. Could this be narrowed to the case being fixed, for example only when stat fails (EACCES) or when the path is under Microsoft\WindowsApps? Ordinary symlinks would then launch exactly as before.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Hona
Hona merged commit 145e948 into dev Nov 7, 2026
23 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Hona
Hona deleted the store-pwsh-newlines branch November 7, 2026 05:39
@opencodejr opencodejr Bot mentioned this pull request Nov 7, 2026
shell: shell executable paths with spaces break all shell tool calls (Windows) #62606
Closed
autonull pushed a commit to autonull/opencode_spacegraph that referenced this pull request Nov 7, 2026
@Hona me
fix(core): keep multi-line commands intact for Store PowerShell 7 (an…
0d64b87
…omalyco#62522)
This was referenced Nov 8, 2026
Shell exits 64 when the Windows pwsh path contains a space #62683
Closed
Multi-line shell command runs only the first line on Windows/PowerShell (regression 2.2.5 to 2.2.6) #62877
Closed
@amrkmn amrkmn mentioned this pull request Nov 10, 2026
opencode 2.2.7 amrkmn/homebrew-tap#1224
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 10, 2026
feat: opencode release v2.2.7 sprisa/opencode-server#85
Merged
@Sniezka1927 Sniezka1927 mentioned this pull request Nov 11, 2026
[Bug]: Shell tool fails on every command when the Windows user folder name contains a space nightly-labs/openbot#6682
Closed
@github-actions github-actions Bot mentioned this pull request Nov 11, 2026
Tool release: OpenCode 2 v2.2.7 (was v2.2.6) agent-sh/agnix#1823
Closed
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 16, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1166
Merged
1 task
@mkobit mkobit mentioned this pull request Nov 18, 2026
Update opencode from 2.2.6 to 2.2.7 mkobit/dotfiles#1099
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

v2.2.6 regression: shell tool returns empty output (exit 0) for every command when Store PowerShell 7 resolves to its app-execution alias

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Hona
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.