Skip to content

fix(sea): accept commands regardless of the executable's filename - #98

Merged
altaywtf merged 1 commit into
mainfrom
fix/sea-executable-name
Oct 1, 2026
Merged

altaywtf merged 1 commit into
mainfrom
fix/sea-executable-name

Conversation

@altaywtf

@altaywtf altaywtf commented Oct 1, 2026

Copy link
Copy Markdown
Member

Summary

The SEA binary now runs commands under any filename. Before, .artifacts/sea/putio-darwin-arm64 version failed with Unknown subcommand ".../putio-darwin-arm64" because argv stripping only recognized putio, putio.exe, or bin.mjs.

  • In a single executable, Node puts the executable path in argv[0] and the invoked name in argv[1], so the CLI now skips both when node:sea reports isSea(), instead of matching on the basename.
  • CliRuntime exposes this as isSingleExecutable; the npm bin.mjs path is unchanged.

Closes #97

Verification

  • pnpm exec vp run verify: pass, 369 tests
  • New cli.test.ts case for SEA argv with a platform-suffixed name; fails with the src/cli.ts change reverted
  • pnpm exec vp run build:sea and verify:sea (darwin-arm64): pass
  • Smoked putio-darwin-arm64 version, putio version, a symlink to the binary, ./dist/bin.mjs version, and node dist/bin.mjs --version: all exit 0

Notes

Only darwin-arm64 was smoked locally; other platforms rely on the release SEA matrix.


Written by an agent (Claude Code, Opus 5.5)

Copilot AI balanced review requested due to automatic review settings October 1, 2026 10:54
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The fix is small, correct per Node SEA argv behavior, fully plumbed through all CliRuntimeService implementations, and covered by a new test plus the documented SEA build/smoke verification.

Review effort: Balanced
Findings: None

What changed in this PR

This PR fixes a bug in the SEA (Single Executable Application) build where the binary rejected every command when invoked under its platform-suffixed filename (e.g. putio-darwin-arm64 version failed with Unknown subcommand). The root cause was that argv stripping relied on matching a hardcoded putio/putio.exe/bin.mjs basename, which did not match the build output name. The fix detects single-executable mode via node:sea's isSea(), exposes it on CliRuntimeService as isSingleExecutable, and uses it to skip Node SEA's two leading argv entries ([execPath, name, ...args]) regardless of filename. This fits cleanly into the existing Effect service/runtime layering, keeping the npm bin.mjs path unchanged.

Changes:

  • Add isSingleExecutable to CliRuntimeService, defaulting to isSea() in makeCliRuntime.
  • In commandArgsFromArgv, strip the first two argv entries when running as a single executable instead of relying on basename matching.
  • Thread the flag through test helpers and add a SEA-argv test; update the hand-written runtime mock.
File Description
src/​internal/​runtime.ts Imports isSea, adds isSingleExecutable to the service type and makeCliRuntime (default isSea()).
src/​cli.ts commandArgsFromArgv now takes isSingleExecutable and strips argv[0]/argv[1] for SEA; passes runtime.isSingleExecutable.
src/​cli.test.ts Adds isSingleExecutable to the test-run options and a new SEA argv parsing test.
src/​internal/​auth-flow.test.ts Adds isSingleExecutable: false to the hand-written CliRuntimeService mock to satisfy the updated type.

I verified that auth-flow.test.ts is the only hand-written implementation of CliRuntimeService (all other call sites use makeCliRuntime, which now supplies a default), that the SEA argv behavior ([execPath, name, ...args]) matches the slice(2) approach, that the npm/node/bin.mjs paths are unaffected, and that the SEA entry point (sea.ts) uses CliRuntimeLive, which resolves isSingleExecutable from isSea() at runtime. The engines field (node >= 24.19.0) guarantees node:sea is available.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@altaywtf
altaywtf merged commit 9ac30ce into main Oct 1, 2026
7 checks passed
@altaywtf
altaywtf deleted the fix/sea-executable-name branch October 1, 2026 11:01
putio-ci Bot added a commit that referenced this pull request Oct 1, 2026
## [1.8.5](v1.8.4...v1.8.5) (2026-10-01)

### Bug Fixes

* **sea:** accept commands regardless of the executable's filename ([#98](#98)) ([9ac30ce](9ac30ce)), closes [#97](#97)
@putio-ci

putio-ci Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.8.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@putio-ci putio-ci Bot added the released label Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(sea): binary rejects every command when invoked under its platform filename

2 participants