fix(workflows): detect compiled binaries via execPath fallback#963
fix(workflows): detect compiled binaries via execPath fallback#963
Conversation
`isBinaryBuild()` only checked whether `import.meta.dir` lives under Bun's
virtual filesystem (`/$bunfs/` or `B:\~BUN\`). In CJS bytecode compiled
binaries (`bun build --compile` with bytecode), `import.meta.dir` is empty
or undefined, so detection silently returned `false`.
Symptoms in the released `archon-linux-x64` binary:
[WARN] Binary installed but version check failed:
Error: Failed to read version: package.json not found (bad installation?)
That error is only thrown by `getDevVersion()` in
`packages/cli/src/commands/version.ts:33` — which the binary should never
reach. Any other code branching on `isBinaryBuild()` (default workflow
loading, embedded resources) was also taking the wrong path.
Add a `process.execPath` basename check as a fallback: if execPath is
neither `bun` nor `node`, the process is running as a standalone compiled
binary. Exported `isCompiledExecPath()` for testability and added unit
tests covering bun/node interpreters and standalone binaries on Linux,
macOS, and Windows.
Also adds `scripts/install-local.{ps1,sh}` — local-file install harnesses
for validating the install flow against a binary built from the current
branch before cutting a release. These were used to verify this fix
end-to-end on Windows; the Linux harness is documented for testing on
Proxmox / fresh Linux VMs.
Fixes #961
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…stream logger
Replaces runtime detection of compiled binaries (env sniffing via
import.meta.dir / process.execPath) with a build-time BUNDLED_IS_BINARY
constant in @archon/paths/bundled-build.ts, rewritten by
scripts/build-binaries.sh and restored on EXIT via a trap.
Also rewrites @archon/paths/logger.ts to use pino-pretty as a destination
stream instead of a worker-thread transport. The formatter now runs on
the main thread, eliminating the require.resolve('pino-pretty') lookup
that crashes inside Bun's /\$bunfs/ virtual filesystem in compiled
binaries. The same code path runs in dev and binaries — no environment
detection in the logger at all.
isBinaryBuild() in @archon/workflows is kept as a one-line wrapper
around BUNDLED_IS_BINARY so existing spyOn-based test mocking in
loader.test.ts continues to work without modification.
Closes #960
Closes #961
Closes #979
Supersedes #962
Supersedes #963
Co-Authored-By: leex279 <leex279@users.noreply.github.com>
…stream logger (#982) * fix(build): use build-time constants for binary detection and pretty stream logger Replaces runtime detection of compiled binaries (env sniffing via import.meta.dir / process.execPath) with a build-time BUNDLED_IS_BINARY constant in @archon/paths/bundled-build.ts, rewritten by scripts/build-binaries.sh and restored on EXIT via a trap. Also rewrites @archon/paths/logger.ts to use pino-pretty as a destination stream instead of a worker-thread transport. The formatter now runs on the main thread, eliminating the require.resolve('pino-pretty') lookup that crashes inside Bun's /\$bunfs/ virtual filesystem in compiled binaries. The same code path runs in dev and binaries — no environment detection in the logger at all. isBinaryBuild() in @archon/workflows is kept as a one-line wrapper around BUNDLED_IS_BINARY so existing spyOn-based test mocking in loader.test.ts continues to work without modification. Closes #960 Closes #961 Closes #979 Supersedes #962 Supersedes #963 Co-Authored-By: leex279 <leex279@users.noreply.github.com> * style(workflows): hoist BUNDLED_IS_BINARY import to top of file * fix(build,logger): harden pretty init and trap restore - logger: wrap pino-pretty init in try/catch and fall back to JSON so a broken TTY or missing peer can't crash module load. - build-binaries.sh: drop '2>/dev/null || true' from the EXIT trap so a failed bundled-build.ts restore is visible instead of silently leaving the dev tree with BUNDLED_IS_BINARY=true. - bundled-defaults: unmark isBinaryBuild() @deprecated and document why the wrapper is the intentional test seam (mock.module pollution in Bun). --------- Co-authored-by: leex279 <leex279@users.noreply.github.com>
|
Closing — superseded by #982 which replaces both this PR and #963 with a build-time constants refactor ( Why the architectural redirect: the runtime detection approach needed two ANDed heuristics per package ( For the logger specifically: #982 uses Thank you @leex279 for catching the underlying bugs in #960/#961 and providing the initial fixes here. Your diagnosis drove the refactor; the new implementation credits you in its commit message. The |
Reused worktrees were never checked against the configured baseBranch, so PRs could silently target the wrong base after a config change. Changes: - Add isAncestorOf() git helper using merge-base --is-ancestor - Add baseBranch field to IsolationHints for opt-in validation - Validate base branch in resolver checkExisting and findReusable paths - Add base branch warning in CLI worktree reuse path - Add tests for isAncestorOf and resolver base branch mismatch Fixes coleam00#963
Reused worktrees were never checked against the configured baseBranch, so PRs could silently target the wrong base after a config change. Changes: - Add isAncestorOf() git helper using merge-base --is-ancestor - Add baseBranch field to IsolationHints for opt-in validation - Validate base branch in resolver checkExisting and findReusable paths - Add base branch warning in CLI worktree reuse path - Add tests for isAncestorOf and resolver base branch mismatch Fixes coleam00#963
…stream logger (coleam00#982) * fix(build): use build-time constants for binary detection and pretty stream logger Replaces runtime detection of compiled binaries (env sniffing via import.meta.dir / process.execPath) with a build-time BUNDLED_IS_BINARY constant in @archon/paths/bundled-build.ts, rewritten by scripts/build-binaries.sh and restored on EXIT via a trap. Also rewrites @archon/paths/logger.ts to use pino-pretty as a destination stream instead of a worker-thread transport. The formatter now runs on the main thread, eliminating the require.resolve('pino-pretty') lookup that crashes inside Bun's /\$bunfs/ virtual filesystem in compiled binaries. The same code path runs in dev and binaries — no environment detection in the logger at all. isBinaryBuild() in @archon/workflows is kept as a one-line wrapper around BUNDLED_IS_BINARY so existing spyOn-based test mocking in loader.test.ts continues to work without modification. Closes coleam00#960 Closes coleam00#961 Closes coleam00#979 Supersedes coleam00#962 Supersedes coleam00#963 Co-Authored-By: leex279 <leex279@users.noreply.github.com> * style(workflows): hoist BUNDLED_IS_BINARY import to top of file * fix(build,logger): harden pretty init and trap restore - logger: wrap pino-pretty init in try/catch and fall back to JSON so a broken TTY or missing peer can't crash module load. - build-binaries.sh: drop '2>/dev/null || true' from the EXIT trap so a failed bundled-build.ts restore is visible instead of silently leaving the dev tree with BUNDLED_IS_BINARY=true. - bundled-defaults: unmark isBinaryBuild() @deprecated and document why the wrapper is the intentional test seam (mock.module pollution in Bun). --------- Co-authored-by: leex279 <leex279@users.noreply.github.com>
Reused worktrees were never checked against the configured baseBranch, so PRs could silently target the wrong base after a config change. Changes: - Add isAncestorOf() git helper using merge-base --is-ancestor - Add baseBranch field to IsolationHints for opt-in validation - Validate base branch in resolver checkExisting and findReusable paths - Add base branch warning in CLI worktree reuse path - Add tests for isAncestorOf and resolver base branch mismatch Fixes coleam00#963
…stream logger (coleam00#982) * fix(build): use build-time constants for binary detection and pretty stream logger Replaces runtime detection of compiled binaries (env sniffing via import.meta.dir / process.execPath) with a build-time BUNDLED_IS_BINARY constant in @archon/paths/bundled-build.ts, rewritten by scripts/build-binaries.sh and restored on EXIT via a trap. Also rewrites @archon/paths/logger.ts to use pino-pretty as a destination stream instead of a worker-thread transport. The formatter now runs on the main thread, eliminating the require.resolve('pino-pretty') lookup that crashes inside Bun's /\$bunfs/ virtual filesystem in compiled binaries. The same code path runs in dev and binaries — no environment detection in the logger at all. isBinaryBuild() in @archon/workflows is kept as a one-line wrapper around BUNDLED_IS_BINARY so existing spyOn-based test mocking in loader.test.ts continues to work without modification. Closes coleam00#960 Closes coleam00#961 Closes coleam00#979 Supersedes coleam00#962 Supersedes coleam00#963 Co-Authored-By: leex279 <leex279@users.noreply.github.com> * style(workflows): hoist BUNDLED_IS_BINARY import to top of file * fix(build,logger): harden pretty init and trap restore - logger: wrap pino-pretty init in try/catch and fall back to JSON so a broken TTY or missing peer can't crash module load. - build-binaries.sh: drop '2>/dev/null || true' from the EXIT trap so a failed bundled-build.ts restore is visible instead of silently leaving the dev tree with BUNDLED_IS_BINARY=true. - bundled-defaults: unmark isBinaryBuild() @deprecated and document why the wrapper is the intentional test seam (mock.module pollution in Bun). --------- Co-authored-by: leex279 <leex279@users.noreply.github.com>
Summary
isBinaryBuild()only checked whetherimport.meta.dirlives under Bun's virtual FS (/$bunfs/orB:\~BUN\). In CJS bytecode compiled binaries (bun build --compilewith bytecode),import.meta.diris empty/undefined and detection silently returnedfalse.archon-linux-x64: installer printsFailed to read version: package.json not found (bad installation?)because the version command falls into the dev-modegetDevVersion()path that tries to readpackage.jsonfrom disk.process.execPathbasename check as a fallback: if execPath isn'tbun/node, the process is a standalone compiled binary. ExportedisCompiledExecPath()for testability.scripts/install-local.{ps1,sh}— local-file install harnesses for validating the install flow against a binary built from the current branch before cutting a release. Used to verify this fix end-to-end on Windows; the.shvariant is for Linux/Proxmox VM smoke testing.Fixes #961
Test plan
bun test packages/workflows/src/defaults/bundled-defaults.test.ts— 18 pass, 0 fail (added 4 new tests forisCompiledExecPathcovering bun/node interpreters and standalone binaries on Linux/macOS/Windows)bun --filter @archon/workflows test— full suite greenbun --filter @archon/workflows type-check— cleanbun build --compile→install-local.ps1→archon versionreportsBuild: binary(was reporting dev path before).install-local.sh(pending hardware access)devRelated
Stacked alongside #962 (pino-pretty transport fix). Both are needed before the next binary release is usable end-to-end.