QA lab: respect homedir fallback for CODEX_HOME

This commit is contained in:
Mason Huang
2026-04-15 13:28:55 +08:00
parent e2d96f13af
commit f297ebf0dd
2 changed files with 4 additions and 2 deletions

View File

@@ -181,6 +181,7 @@ describe("qa multipass runtime", () => {
const fakeCodexHome = path.join(fakeHome, ".codex");
fs.mkdirSync(fakeCodexHome, { recursive: true });
vi.stubEnv("HOME", "");
vi.stubEnv("CODEX_HOME", "");
vi.spyOn(os, "homedir").mockReturnValue(fakeHome);
try {

View File

@@ -280,8 +280,9 @@ function resolveQaLiveCliAuthEnv(baseEnv: NodeJS.ProcessEnv) {
const codexHome = resolveUserPath(configuredCodexHome, baseEnv);
return fs.existsSync(codexHome) ? { CODEX_HOME: codexHome } : {};
}
const hostHome = baseEnv.HOME?.trim() || os.homedir();
const codexHome = path.join(hostHome, ".codex");
const hostHome = baseEnv.HOME?.trim();
const effectiveHome = hostHome || os.homedir();
const codexHome = path.join(effectiveHome, ".codex");
return fs.existsSync(codexHome) ? { CODEX_HOME: codexHome } : {};
}