Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/daemon/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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);
}