Repository navigation
fix(core): retry failed ripgrep resolution and sanitize PowerShell 5.1 module path on Windows - #41015
Closed
Yuxin-Qiao wants to merge 1 commit into
Closed
Yuxin-Qiao wants to merge 1 commit into
Yuxin-Qiao wants to merge 1 commit into
Conversation
…1 module path on Windows Two Windows grep/glob failures from anomalyco#40623: - the ripgrep resolution was wrapped in Effect.cached, which memoizes failures too, so one failed download/extraction poisoned every grep and glob call until the process was restarted. Replace it with a single-flight memo that only caches successful resolutions, so the next call retries. - zip extraction spawns powershell.exe, which inherits PSModulePath from the launching shell. When opencode is launched from the MSIX build of PowerShell 7, that path lists the Core-edition modules first and Expand-Archive autoload fails inside the 5.1 child. Pin the child's PSModulePath to the inbox 5.1 module directory.
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes both root causes of grep/glob failing on Windows from #40623:
RipgrepBinary.filepathwrapped the locate/download/extract effect inEffect.cached, which memoizes failures as well as successes. A single failed download or extraction (e.g. the PowerShell issue below) poisoned everygrep/globcall in that process — even after the user fixed the environment (e.g. placedrg.exein~/.cache/opencode/bin/) — until opencode was restarted. Replaced with a single-flight memo that caches only successful resolutions, so the next call retries.powershell.exe(Windows PowerShell 5.1) withExpand-Archive, and the child inheritsPSModulePathfrom the launching shell. When opencode is started from the Microsoft Store (MSIX) build of PowerShell 7, that variable lists the Core-edition module directory first; the 5.1 module autoloader deems it incompatible and stops searching, soExpand-Archivefails withCouldNotAutoloadMatchingModuleand the downloaded zip is never extracted. The child now gets a pinnedPSModulePathpointing at the inbox 5.1 module directory (%SystemRoot%\System32\WindowsPowerShell\v1.0\Modules) when the resolved shell ispowershell.exe.pwsh.exespawns are untouched.Test
packages/core/test/ripgrep-binary.test.ts:memoizeSuccessmemoizes a successful resolution (runs once)memoizeSuccessretries a failed resolution instead of caching the failure, then caches the eventual successwindowsPowerShell5ModulePathhonorsSystemRootand falls back toC:\Windowsbun test test/ripgrep.test.ts test/ripgrep-binary.test.ts test/filesystem/search.test.ts— 8 pass / 0 failbun run typecheck(tsgo) — cleanoxlint— no new warnings (the unbound-method pattern matches the existingSemaphore.makeUnsafe(1).withPermitusage insession/runner/llm.ts)Refs #40623