#7591 · Service environment omits the installer home
REPRODUCED · Root-cause confidence: high
The verdict covers the actual installer-generated unit and an isolated Git subprocess. A real systemd enrollment was not run: this investigation host has dumb-init, not systemd, as PID 1.
1. TL;DR
The Linux installer knows its home directory, but the systemd unit it writes does not preserve that directory in the service environment. Its root/system-manager path also does not specify a service user. The installer’s existing two-case service test successfully installs the unit yet misses this omission. Adding one environment-contract assertion makes both cases fail on unchanged production code in two clean checkouts. Separately, an isolated Git subprocess fails with exit 128 without HOME and reads a disposable profile successfully when HOME is supplied; no credentials or existing profiles are needed.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| The root installer writes a system-level unit without HOME. | Verified | Executed the trusted installer through its existing root/system-manager fixture; the emitted unit has BB_DATA_DIR and BB_APP_NPM_PREFIX but no HOME or User directive. |
| The generated user/container unit also omits HOME. | Verified, with a limit | The second table case emits the same environment omission. A user manager may already supply HOME, so omission alone does not establish failure for every user service. |
| Missing HOME prevents Git’s global configuration lookup. | Verified | Fresh subprocess environments and a disposable .gitconfig produce exit 128 without HOME and exit 0 with HOME. |
| The installer’s unset-HOME recovery repairs the eventual service. | Refuted | The recovery exports HOME only in the installer process; the generated service does not persist it. |
| The reported distribution/systemd versions and two affected enrolled machines exhibit this behavior. | Not directly verified | No access to reporter machines; no real enrollment, real system manager, provider, or credential lookup was used. |
| Paths with spaces and percent signs are handled correctly by a future fix. | Not tested | The trusted installer already has a systemd escaping helper, but no production fix was applied in this investigation. |
3. Environment
- Trusted source: get-bb/bb origin/main at
da3e60b81d560e114a2bec724bb59c997aaaae7f, fetched again before publication with no newer main commit. - Debian GNU/Linux 12, Node.js v22.19.0, Git 2.39.5; PID 1 is dumb-init.
- Two separate detached worktrees, designated
WORK/baseandWORK/verify, created with mktemp under /tmp. Both started clean at the recorded SHA. Only the same one-line test assertion was added; production files stayed unchanged. - The existing fixture creates temporary data/home directories and local fake daemon listeners; its recorded selected port was 38889. No real BB app, enrolled machine, provider, or public listener was used. Fresh fixture directories and listeners were created for the second run.
4. Minimal reproduction
Use a clean checkout of the recorded trusted commit. This extends the existing executed-installer test, not a source-text assertion. The assertion guards the environment contract of the emitted service file. Existing assertions cover service supervision but do not check the child configuration home.
git clone https://github.com/get-bb/bb.git bb-7591
cd bb-7591
git checkout --detach da3e60b81d560e114a2bec724bb59c997aaaae7f
pnpm install --frozen-lockfile --prefer-offline
apply_patch <<'PATCH'
*** Begin Patch
*** Update File: apps/server/test/app/install-machine-script.test.ts
@@
expect(unit).toContain(
`Environment="BB_APP_NPM_PREFIX=${realpathSync(fixture.dataDir)}/npm"`,
);
+ expect(unit).toContain(`Environment="HOME=${fixture.homeDir}"`);
expect(unit).toContain(
container ? "WantedBy=default.target" : "WantedBy=multi-user.target",
*** End Patch
PATCH
pnpm exec turbo run test --filter=@bb/server -- test/app/install-machine-script.test.ts -t 'installs a persistent root system unit'
Expected: both selected cases install a unit that preserves the fixture home; the two cases pass. Actual: both installer invocations succeed, then both fail specifically at the added HOME assertion. The failed-test names and final result below are verbatim except that Turbo's package-prefix decoration is omitted.
FAIL |@bb/server| test/app/install-machine-script.test.ts > machine install script > installs a persistent root system unit (container=false) FAIL |@bb/server| test/app/install-machine-script.test.ts > machine install script > installs a persistent root system unit (container=true) Tests 2 failed | 52 skipped (54)
The system-unit output contains the following exact non-path excerpt; neither HOME nor User is present anywhere in the emitted unit.
Restart=always RestartSec=2 OOMPolicy=continue [Install] WantedBy=multi-user.target
Standalone child configuration probe: save as home-probe.mjs and run node home-probe.mjs
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
const directory = mkdtempSync(join(tmpdir(), "bb-home-probe-"));
const baseEnvironment = {
PATH: "/usr/bin:/bin",
XDG_CONFIG_HOME: directory,
GIT_CONFIG_NOSYSTEM: "1",
};
try {
writeFileSync(join(directory, ".gitconfig"), "[user]\nname = Fixture User\n");
for (const hasHome of [false, true]) {
const result = spawnSync("git", ["config", "--global", "user.name"], {
cwd: directory,
env: hasHome ? { ...baseEnvironment, HOME: directory } : baseEnvironment,
encoding: "utf8",
});
console.log(JSON.stringify({
homeSupplied: hasHome,
status: result.status,
stdout: result.stdout.trim(),
stderr: result.stderr.trim(),
}));
assert.equal(result.status, hasHome ? 0 : 128);
if (hasHome) {
assert.equal(result.stdout.trim(), "Fixture User");
} else {
assert.match(result.stderr, /HOME not set/);
}
}
} finally {
rmSync(directory, { recursive: true, force: true });
}The probe passed in both runs with this exact output:
{"homeSupplied":false,"status":128,"stdout":"","stderr":"fatal: $HOME not set"}
{"homeSupplied":true,"status":0,"stdout":"Fixture User","stderr":""}
5. Root cause
Installer HOME recovery and root/system scope selection happen in the installer process. Later, the generated unit includes only these environment entries:
Environment="BB_APP_NPM_PREFIX=$escaped_bb_app_npm_prefix" Environment="BB_DATA_DIR=$escaped_data_dir"
A newly started system service does not inherit the installer’s shell environment merely because the installer called systemctl. If the manager supplies no HOME, this unit supplies none either. No User directive requests account-context initialization on that root system-unit path. The missing value can then reach child CLIs: child-environment sanitization copies existing variables and removes BB_* and NODE_ENV, but does not populate HOME. Provider spawning and terminal environment assembly use this inherited environment plus explicit overrides. An override or login shell can mask the omission; none is guaranteed by the unit itself.
The deeper boundary error is treating recovery in the short-lived installer as recovery in a separately supervised daemon. The isolated Git probe verifies the resulting configuration-lookup mechanism, without claiming to have run the reporter’s actual enrolled machine.
6. Proposed fix and autopilot decision
Persist the intended home in the generated systemd Environment directive using the existing systemd escaping helper. Do not alter the service’s execution user as a shortcut. Check whitespace, percent, quote and backslash escaping, and preserve a deliberately configured home. Consider a separately reviewed POSIX daemon-start fallback for already-installed services, since an installer-only repair will not rewrite existing units.
No automated fix PR: changing the generated machine-service installer is a packaging change, expressly excluded by this rule’s simple-fix gate. A startup fallback would additionally span the installer and host-daemon startup subsystems. No production fix, branch push, or pull request was made; the local reproduction changes only one test line.
7. Linked PR review
PR #7592 appeared as a cross-reference during this investigation. GitHub metadata records it as closed and unmerged, with six changed files, 74 additions and six deletions. No linked branch was checked out or run.
Static inspection only: its installer diff persists HOME through the existing escaping helper, and its daemon diff adds a missing-HOME fallback before start configuration loads. Those changes address the observed missing-value mechanism and attempt to cover existing services. They are not validated by the tests in this report; all reported executions used trusted main plus our independently written one-line assertion. The six-file, two-subsystem change also falls outside this rule’s five-file/one-subsystem gate. No claim is made about the PR’s reported test results.
8. Related issues
#6773 is a different service-install defect involving a transient Node executable path. Trusted history shows that fix in commit 21ff1a47f7; current installer source still omits HOME, so that repair does not resolve this environment defect.
9. Verification
The same agent repeated the reproduction in a second clean detached checkout at the exact recorded SHA, with a separate frozen installation and new temporary fixture directories/listeners. The command was identical to section 4. Both selected cases failed at the same added assertion, with 2 failed | 52 skipped (54). The standalone Git probe was rerun and emitted the identical two JSON records. This is a second clean reproduction, not independent verification by another agent.
First run: 7.43 seconds in Vitest. Second run: see the same two-case failure summary; Turbo reran the server test rather than reporting a cached test result. Production code was unchanged in both checkouts. No correction to the root-cause conclusion was needed; confidence is high for unit generation and child-environment propagation, with real systemd enrollment explicitly untested.
10. Appendix and limits
- Setup commands:
git fetch origin main; twogit worktree add --detachoperations at the pinned SHA;pnpm install --frozen-lockfile --prefer-offlinein each checkout. - The requested workspace-wide
pnpm exec turbo run buildfailed on trusted main because plugin builds could not resolve the plugin SDK’s missing dist/index.js.pnpm exec turbo run build:types --filter=@get-bb/plugin-sdksucceeded but did not alone fix that broad build. The focused Turbo test subsequently built its runtime dependencies and reached both intended assertion failures. No broad-build success is claimed, and unrelated build code was not changed. - Diagnostic diff: one added line, zero removed lines, one test file;
git diff --checkpassed. No binary, dependency, lockfile, migration, or production change. - Issue data and linked PR content were treated only as untrusted claims; no external issue link was fetched and no issue/PR script, patch, test, or branch was executed.
- No screenshots: this is an installer/child-process defect, not a visual issue. Reproduction code and exact child-process output are inline in this report. Raw local logs and the patch stay outside the public report repository as required by that repository’s publication policy.