Skip to content

fix(ripgrep): use non-scoped temp directory to prevent premature cleanup (#23411)#23412

Closed
kagura-agent wants to merge 1 commit intoanomalyco:devfrom
kagura-agent:fix/ripgrep-extraction-scoped-cleanup
Closed

fix(ripgrep): use non-scoped temp directory to prevent premature cleanup (#23411)#23412
kagura-agent wants to merge 1 commit intoanomalyco:devfrom
kagura-agent:fix/ripgrep-extraction-scoped-cleanup

Conversation

@kagura-agent
Copy link
Copy Markdown

@kagura-agent kagura-agent commented Apr 19, 2026

Issue for this PR

Closes #23411

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The extract helper in ripgrep.ts wraps its body with Effect.scoped, so the temp directory created by makeTempDirectoryScoped gets deleted as soon as extract returns. The caller then calls fs.exists(extracted) on a path inside that deleted directory and fails with "ripgrep archive did not contain executable".

Fix: switch to makeTempDirectory (non-scoped) and manually clean up the temp directory after copying the binary out, or on error.

How did you verify your code works?

Traced the Effect scoping lifecycle: makeTempDirectoryScoped registers a finalizer in the current scope; Effect.scoped on extract closes that scope on return. The caller needs the extracted path after extract returns, so the temp dir must outlive the call. Verified the fix preserves cleanup on both success and error paths.

Checklist

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

…nup (anomalyco#23411)

The extract helper wraps makeTempDirectoryScoped with Effect.scoped,
causing the temp directory to be deleted when extract returns — before
the caller can check the extracted binary or copy it to the target path.

Switch to makeTempDirectory (non-scoped) and manually remove the temp
directory after the copy succeeds or on error.
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

The search results only return the current PR (#23412 - note the title references #23411, which is the issue number). The only other potentially related result is PR #13514 about memory leaks, which doesn't appear to be directly related to the ripgrep temp directory issue.

No duplicate PRs found

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@kagura-agent
Copy link
Copy Markdown
Author

Closing this PR — the upstream dev branch has since refactored the extract function to perform copyFile + chmod inside the Effect.scoped block (before the temp directory is cleaned up), which is a cleaner fix for the same issue. The scoped temp dir no longer outlives its use. 🎉

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ripgrep broken after upgrading to opencode 1.14.18

1 participant