fix: detect Bun compiled binary when import.meta.url percent-encodes ~BUN - #208
Conversation
…~BUN On Windows, the compiled binary's virtual filesystem root B:\~BUN\ shows up in import.meta.url with the tilde percent-encoded (file:///B:/%7EBUN/root/...), so isCompiledBinary() returned false and the binary tried to resolve the Agent SDK from node_modules instead of downloading the pinned executable. Both v0.20.0 Windows smoke tests failed on exactly this, which kept the release draft unpublished. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Greptile SummaryThis PR fixes Bun standalone-binary detection for percent-encoded Windows virtual-filesystem URLs.
Confidence Score: 4/5The PR appears safe to merge, with a non-blocking path-boundary hardening opportunity in the new encoded-marker check. The intended Windows standalone URL is now detected, but matching Files Needing Attention: src/lib/agent-sdk-assets.ts Important Files Changed
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/lib/agent-sdk-assets.ts:64
**Unbounded virtual-filesystem marker match**
The new check accepts `%7EBUN` anywhere in a source-mode module URL, so an ordinary path containing a `~BUN` component is classified as compiled and unnecessarily enters the download-and-cache flow instead of resolving the installed node_modules asset. Match the documented virtual-filesystem segment, such as `%7EBUN/root/`, to avoid breaking offline use from such paths.
Reviews (1): Last reviewed commit: "fix: detect Bun compiled binary when imp..." | Re-trigger Greptile |
| * tests. | ||
| */ | ||
| export function isBunVirtualFsUrl(url: string): boolean { | ||
| return url.includes('$bunfs') || url.includes('~BUN') || url.includes('%7EBUN'); |
There was a problem hiding this comment.
Unbounded virtual-filesystem marker match
The new check accepts %7EBUN anywhere in a source-mode module URL, so an ordinary path containing a ~BUN component is classified as compiled and unnecessarily enters the download-and-cache flow instead of resolving the installed node_modules asset. Match the documented virtual-filesystem segment, such as %7EBUN/root/, to avoid breaking offline use from such paths.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/lib/agent-sdk-assets.ts
Line: 64
Comment:
**Unbounded virtual-filesystem marker match**
The new check accepts `%7EBUN` anywhere in a source-mode module URL, so an ordinary path containing a `~BUN` component is classified as compiled and unnecessarily enters the download-and-cache flow instead of resolving the installed node_modules asset. Match the documented virtual-filesystem segment, such as `%7EBUN/root/`, to avoid breaking offline use from such paths.
How can I resolve this? If you propose a fix, please make it concise.
Why
The v0.20.0 release failed both Windows smoke tests with:
isCompiledBinary()checksimport.meta.urlfor$bunfs(POSIX) or~BUN(Windows). But Bun's URL serializer (WebKitWTF::URL::fileURLWithFileSystemPath) percent-encodes the tilde, so on Windows the URL isfile:///B:/%7EBUN/root/…— neither marker matches. The compiled binary then took the dev-mode path and tried to resolve the Agent SDK from node_modules, which doesn't exist in a standalone binary.Verified empirically (same serializer as
Bun.pathToFileURL):POSIX targets were unaffected because
$isn't percent-encoded, which is why all six macOS/Linux smoke tests passed.What
isBunVirtualFsUrl()and additionally match the percent-encoded%7EBUNform.Note:
Bun.isStandaloneExecutableis the official API for this, but it shipped after Bun 1.3.14 (the version CI pins), so the URL heuristic stays.Verification
bun run test(2033 pass),bun run typecheck,bun run buildall green.internal verify-assetson real Windows hardware before anything publishes.🤖 Generated with Claude Code