{"record":{"id":"fb65a765757623e4","repo":"EveryInc/compound-engineering-plugin","slug":"home-is-not-set","errorCode":null,"errorMessage":"HOME is not set","messagePattern":"HOME is not set","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/dev/codex-dev.ts","lineNumber":178,"sourceCode":"  for (const entry of entries) {\n    if (!entry.isDirectory() && !entry.isSymbolicLink()) continue\n    try {\n      const stat = await fs.stat(path.join(skillsRoot, entry.name, \"SKILL.md\"))\n      if (stat.isFile()) names.push(entry.name)\n    } catch (error) {\n      if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error\n    }\n  }\n  return names.sort()\n}\n\nexport async function resolveCodexDevContext(\n  cwd: string,\n  env: NodeJS.ProcessEnv = process.env,\n  runner: CommandRunner = new BunCommandRunner(),\n): Promise<CodexDevContext> {\n  const home = env.HOME\n  if (!home) throw new Error(\"HOME is not set\")\n\n  const options = { cwd, env }\n  const repoRootRaw = trim(await checkedRun(runner, \"git\", [\"rev-parse\", \"--show-toplevel\"], options))\n  const repoRoot = await fs.realpath(repoRootRaw)\n  await assertCompoundEngineeringRepo(repoRoot)\n\n  const gitDir = trim(\n    await checkedRun(runner, \"git\", [\"rev-parse\", \"--path-format=absolute\", \"--absolute-git-dir\"], {\n      cwd: repoRoot,\n      env,\n    }),\n  )\n  const gitCommonDir = trim(\n    await checkedRun(runner, \"git\", [\"rev-parse\", \"--path-format=absolute\", \"--git-common-dir\"], {\n      cwd: repoRoot,\n      env,\n    }),\n  )","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/EveryInc/compound-engineering-plugin/blob/c9c10f8c75412c7232cb2bd663e5fd1cea98d84e/src/dev/codex-dev.ts#L160-L196","documentation":"resolveCodexDevContext reads HOME from the environment to locate $CODEX_HOME or ~/.codex and resolve home-relative paths. If HOME is unset or empty it throws immediately, because every subsequent path resolution would be meaningless. This is a hard precondition, not a recoverable state.","triggerScenarios":"Calling resolveCodexDevContext (via the context/firstContext/makeContext helpers or the CLI) with env.HOME undefined or empty string — e.g. a stripped environment passed as the second argument, or a shell/service with no HOME set (src/dev/codex-dev.ts:178).","commonSituations":"Running the CLI under cron/systemd/CI with a minimal env; invoking via env -i or a container exec without -e HOME; a test passing a hand-built env object that forgot HOME.","solutions":["Export HOME in the current shell: export HOME=/home/<user>, then re-run.","If invoked from a service/CI, add HOME to the job's environment block.","Alternatively set CODEX_HOME explicitly — but note HOME is still required by this code path, so fix HOME regardless.","In tests, pass a complete fake env: { ...process.env, HOME: tmpDir }."],"exampleFix":"// before: test setup\nconst ctx = await resolveCodexDevContext(cwd, { PATH: \"/usr/bin\" })\n// after\nconst ctx = await resolveCodexDevContext(cwd, { PATH: \"/usr/bin\", HOME: tmpHome })","handlingStrategy":"validation","validationCode":"if (!process.env.HOME) {\n  throw new Error(\"HOME must be set before running codex:dev (export HOME=/home/<user>)\")\n}","typeGuard":null,"tryCatchPattern":"try {\n  await resolveCodexDevContext(cwd)\n} catch (error) {\n  if ((error as Error).message === \"HOME is not set\") {\n    console.error(\"Set HOME in your environment (shell profile, CI env block, or env -i fallback)\")\n    process.exitCode = 1\n  } else throw error\n}","preventionTips":["Always export HOME in CI jobs, containers (docker exec -e HOME=...), and cron wrappers.","In tests, spread process.env or supply a fake HOME instead of a minimal env object.","Check `echo $HOME` before scripted invocations of the dev workflow."],"tags":["environment","config","home"],"backgroundTag":"missing-env-var","analyzedSha":"c9c10f8c75412c7232cb2bd663e5fd1cea98d84e","analyzedAt":"2026-08-31T15:18:07.959Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}