Repository navigation
cli: read the version through a static import, so a compiled binary starts - #630
Merged
ronleizrowice-ant merged 2 commits intoOct 5, 2026
Merged
Conversation
…tarts
`srt` built into a single file with `bun build --compile` exits before
it parses any argument:
Fatal error: error: Cannot find module '../package.json' from
'/$bunfs/root/srt-bun'
anthropics#571 made `getPackageVersion` load the manifest with
`createRequire(import.meta.url)('../package.json')`, which is resolved
at run time. From `dist/cli.js` that finds the package's own manifest,
but a compiled binary's module lives in Bun's virtual filesystem and
has no manifest beside it, so the require throws. The CLI calls
`getPackageVersion` while it builds the commander program, so every
invocation fails, not only `--version`.
anthropics#592's new bundled test compiles a program that imports `dist/` with
`bun build --compile`, which is the library path embedders use. It
never compiles `src/cli.ts`, so it does not reach this.
A static JSON import (`with { type: 'json' }`) resolves the same file
for `tsc`'s output, where `dist/cli.js` still reads `../package.json`
at load time as before, and lets Bun embed the manifest in a compiled
binary. The unused `createRequire` import goes, and the comment says
why the import is static. The no-fallback rule the comment states is
unchanged: a missing manifest still fails rather than printing a
made-up version.
Checked on macOS:
- `npm run build`, `npm run typecheck` and `eslint src/cli.ts` pass
- `node dist/cli.js --version` prints 0.0.77
- `bun build --compile --minify src/cli.ts` gives a binary that prints
0.0.77 and sandboxes as expected: a write to the home folder is
refused, the network is closed without an allowlist, and with
`allowedDomains: ["example.com"]` only that host is reachable
- `bun test` gives the same results with and without the change here
(1201 pass, 4 fail both ways: three need ripgrep installed, one is a
3 s timing test)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 30, 2026
ronleizrowice-ant
added a commit
that referenced
this pull request
Oct 2, 2026
Clean. An outside contributor's fix: `srt` compiled to a single file starts.
ronleizrowice-ant
enabled auto-merge (squash)
October 5, 2026 17:20
Merged
ronleizrowice-ant
added a commit
that referenced
this pull request
Oct 7, 2026
New to the bundle: #655, #660 and the version. #643, #639 and #630 come as squashes of what it held; in the one block git marks, the workflow's, it keeps its own side, which has the checksummed bun as well. Two cases of #655 compare two wrapped commands. Here a wrap that names mount points names a manifest of its own (#584), so the cases take that name out before they compare.
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.
srtbuilt withbun build --compileexits at start withCannot find module '../package.json'. #571 madegetPackageVersionload the manifest withcreateRequireat runtime, and a single-file binary has no manifest beside it. #592's bundled test compiles a program that importsdist/, not the CLI, so it doesn't reach this.dist/cli.jsresolves the same file as before, and Bun embeds it in the binarynpm run build,typecheckandlintpass, andbun testmatchesmainlocallynode dist/cli.js --versionand the compiled binary both print0.0.77, and the binary sandboxes as expected on macOS🤖 Generated with Claude Code