Repository navigation
fix(core): retry failed ripgrep resolution and sanitize PowerShell 5.1 module path on Windows - #41028
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.
Author
|
Closing for now — I'm a bit tired and don't have bandwidth to keep maintaining this, and there's been no review activity.\n\nThe fix (retry failed ripgrep resolution + sanitize PowerShell 5.1 module path on Windows — |
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.
Issue for this PR
Closes #40623
Type of change
What does this PR do?
grep/glob fail on Windows for two independent reasons, both fixed here.
RipgrepBinary.filepathwrapped the locate/download/extract effect inEffect.cached, which memoizes failures as well as successes. One failed download or extraction poisoned everygrep/globcall in that process until opencode was restarted — even after the user fixed the environment. 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.How did you verify your code works?
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 fail (re-run after rebasing onto latestdev)bun run typecheck(tsgo) — cleanScreenshots / recordings
N/A — core fix, no UI change.
Checklist