Skip to content

fix(core): resolve Windows shells installed as app-execution aliases - #48968

Closed
Hotragn wants to merge 3 commits into
anomalyco:devfrom
Hotragn:windows-pwsh-alias-v2
Closed

Hotragn wants to merge 3 commits into
anomalyco:devfrom
Hotragn:windows-pwsh-alias-v2

Conversation

@Hotragn

@Hotragn Hotragn commented Sep 14, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #55255

Type of change

  • Bug fix

What does this PR do?

A shell installed from the Microsoft Store — most commonly pwsh — is not found, so setting shell: "pwsh" silently falls back to Windows PowerShell 5.1.

Store/MSIX installs expose their executable as an app-execution alias: a zero-byte AppExecLink reparse point on PATH. CreateProcess resolves it by name, but stat reports nothing and which skips it. executable() in shell/select.ts resolves non-rooted names through which, so the shell comes back as "not installed" and selection moves on without telling the user.

Measured on a Windows 11 box, using winget (always an alias) as the probe:

probe result
fs.existsSync(alias) false
fs.statSync(alias) undefined
spawnSync("winget") status 0

where.exe does see aliases, so it distinguishes "installed as an alias" from "not installed". The fallback is scoped narrowly: win32 only, only for a name already in META, and only after which has failed — so it cannot make an unrelated or absent binary resolve.

This also looks like the root cause behind #30615 and #17372.

How did you verify your code works?

packages/core/test/shell.test.ts — 11/11 pass. Added a case asserting that a known-but-absent shell (zsh, ksh) still falls back rather than resolving to its own bare name, which is the regression this fallback could otherwise introduce. Verified where.exe returns 0 for an installed alias and 1 for an absent shell on the same machine.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

Why it's related: This PR has the exact same title and addresses the same issue (Windows Store/MSIX shell installations not being resolved). It appears to be a previous attempt at the same fix. You should verify whether #43323 is still open, closed, or merged, and consider whether this PR (48968) supersedes it or if there's redundant work being done.

@Hotragn

Hotragn commented Sep 14, 2026

Copy link
Copy Markdown
Author

The needs:issue label looks like it was applied before the description was saved — the body does link the issue (Closes #41426, which is open). Happy to adjust the wording if the check wants a different format.

@Hotragn

Hotragn commented Sep 16, 2026

Copy link
Copy Markdown
Author

Confirming the flag: #43323 is mine and is the same fix targeting dev. This one targets v2, which AGENTS.md on that branch asks PRs to default to, and it is not a cherry-pick — the resolution logic moved to shell/select.ts (executable()), so it needed porting. It also carries the review feedback from #43323: memoized lookups and an absolute path instead of a bare name. Happy to close #43323 in favour of this one if that's cleaner.

@Hotragn
Hotragn force-pushed the windows-pwsh-alias-v2 branch from 256f546 to ab48114 Compare September 30, 2026 05:20
@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:08
@github-actions

Copy link
Copy Markdown
Contributor

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.

Windows: pwsh installed as a Store app-execution alias is not resolved, so the shell falls back to Windows PowerShell 5.1

1 participant