From 47d1f23d5552c6ae186249e61d845e4b955486ff Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 19 Jan 2026 08:39:12 +0000 Subject: [PATCH] fix(daemon): include HOME in service env (#1214) Thanks @ameno-. Co-authored-by: Ameno Osman --- CHANGELOG.md | 1 + src/daemon/service-env.test.ts | 16 +++++++++++++++- src/daemon/service-env.ts | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c80584414..487712a07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Docs: https://docs.clawd.bot - Plugins: surface plugin load/register/config errors in gateway logs with plugin/source context. - Agents: propagate accountId into embedded runs so sub-agent announce routing honors the originating account. (#1058) - Compaction: include tool failure summaries in safeguard compaction to prevent retry loops. (#1084) +- Daemon: include HOME in service environments to avoid missing HOME errors. (#1214) — thanks @ameno-. - TUI: show generic empty-state text for searchable pickers. (#1201) — thanks @vignesh07. - Doctor: canonicalize legacy session keys in session stores to prevent stale metadata. (#1169) - CLI: centralize CLI command registration to keep fast-path routing and program wiring in sync. (#1207) — thanks @gumadeiras. diff --git a/src/daemon/service-env.test.ts b/src/daemon/service-env.test.ts index dcc9e31ca..aa7fbca5d 100644 --- a/src/daemon/service-env.test.ts +++ b/src/daemon/service-env.test.ts @@ -1,6 +1,10 @@ import path from "node:path"; import { describe, expect, it } from "vitest"; -import { buildMinimalServicePath, buildServiceEnvironment } from "./service-env.js"; +import { + buildMinimalServicePath, + buildNodeServiceEnvironment, + buildServiceEnvironment, +} from "./service-env.js"; describe("buildMinimalServicePath", () => { it("includes Homebrew + system dirs on macOS", () => { @@ -48,6 +52,7 @@ describe("buildServiceEnvironment", () => { port: 18789, token: "secret", }); + expect(env.HOME).toBe("/home/user"); if (process.platform === "win32") { expect(env.PATH).toBe(""); } else { @@ -75,3 +80,12 @@ describe("buildServiceEnvironment", () => { } }); }); + +describe("buildNodeServiceEnvironment", () => { + it("passes through HOME for node services", () => { + const env = buildNodeServiceEnvironment({ + env: { HOME: "/home/user" }, + }); + expect(env.HOME).toBe("/home/user"); + }); +}); diff --git a/src/daemon/service-env.ts b/src/daemon/service-env.ts index ba2e3b225..8851cdb59 100644 --- a/src/daemon/service-env.ts +++ b/src/daemon/service-env.ts @@ -75,6 +75,7 @@ export function buildServiceEnvironment(params: { (process.platform === "darwin" ? resolveGatewayLaunchAgentLabel(profile) : undefined); const systemdUnit = `${resolveGatewaySystemdServiceName(profile)}.service`; return { + HOME: env.HOME, PATH: buildMinimalServicePath({ env }), CLAWDBOT_PROFILE: profile, CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR, @@ -94,6 +95,7 @@ export function buildNodeServiceEnvironment(params: { }): Record { const { env } = params; return { + HOME: env.HOME, PATH: buildMinimalServicePath({ env }), CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR, CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH,