From 027518aaaef9cba0225d46b464637af864f9f28a Mon Sep 17 00:00:00 2001 From: Peter Dedene Date: Mon, 16 Mar 2026 13:38:21 +0100 Subject: [PATCH] fix(daemon): skip Bun virtual entry path in detached child spawn In Bun compiled binaries, process.argv[1] is a virtual /$bunfs/... path that Bun auto-injects into every spawned child process. The daemon launcher was including this path explicitly in the spawn args, causing it to appear twice in the child's argv. The child then parsed the duplicate path as the CLI command instead of "daemon", silently failing to start. Detect the /$bunfs/ prefix and omit the entry from spawn args, letting Bun handle it automatically. --- src/daemon/launch.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/daemon/launch.ts b/src/daemon/launch.ts index 504f54f..162369e 100644 --- a/src/daemon/launch.ts +++ b/src/daemon/launch.ts @@ -15,7 +15,7 @@ export function launchDaemonDetached(options: DaemonLaunchOptions): void { const configArgs = options.configExplicit ? ['--config', options.configPath] : []; const args = [ ...process.execArgv, - cliEntry, + ...(cliEntry ? [cliEntry] : []), ...configArgs, ...(options.rootDir ? ['--root', options.rootDir] : []), 'daemon', @@ -36,10 +36,16 @@ export function launchDaemonDetached(options: DaemonLaunchOptions): void { child.unref(); } -function resolveCliEntry(): string { +function resolveCliEntry(): string | undefined { const entry = process.argv[1]; if (!entry) { throw new Error('Unable to resolve mcporter entry script.'); } + // In Bun compiled binaries, argv[1] is a virtual /$bunfs/... path that Bun + // auto-injects into every spawned child. Including it explicitly would + // duplicate it and break CLI argument parsing in the child process. + if (entry.startsWith('/$bunfs/')) { + return undefined; + } return path.resolve(entry); }