From affb7a50e47e1531c4c2b33217ff76d4741775b7 Mon Sep 17 00:00:00 2001 From: digua Date: Sat, 30 May 2026 13:59:07 +0800 Subject: [PATCH] fix(daemon): quote ExecStart argv to handle paths with spaces on Linux Wraps each argument in double quotes when building the systemd unit's ExecStart= line, so installs under paths containing spaces (e.g. home directories with spaces, nvm paths) no longer cause systemd to mis-tokenize the command and fail to start the service. Co-Authored-By: Claude Sonnet 4.6 --- apps/cli/src/daemon/service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/cli/src/daemon/service.ts b/apps/cli/src/daemon/service.ts index a63f23f3..a9dd3e40 100644 --- a/apps/cli/src/daemon/service.ts +++ b/apps/cli/src/daemon/service.ts @@ -184,6 +184,10 @@ function statusMacos(): ServiceStatus { // ── Linux (systemd --user) ──────────────────────────────────────────── +function escapeSystemdArg(arg: string): string { + return '"' + arg.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"' +} + function buildUnit(options: ServiceInstallOptions): string { const port = options.port ?? 3110 const host = options.host ?? '127.0.0.1' @@ -191,7 +195,7 @@ function buildUnit(options: ServiceInstallOptions): string { const args = ['start', '--no-open', '--port', String(port), '--host', host] if (options.token) args.push('--token', options.token) if (options.headless) args.push('--headless') - const execStart = [process.execPath, cliEntry, ...args].join(' ') + const execStart = [process.execPath, cliEntry, ...args].map(escapeSystemdArg).join(' ') return `[Unit] Description=ChatLab daemon