Files
openclaw/src/cli/dotenv.ts
scoootscooob 6ab1b43081 fix(dotenv): load gateway.env compatibility fallback (#61084)
* fix(dotenv): load gateway env fallback

* fix(dotenv): preserve legacy cli env loading

* fix(dotenv): keep gateway fallback scoped to default profile
2026-04-04 18:24:29 -07:00

18 lines
693 B
TypeScript

import path from "node:path";
import { resolveStateDir } from "../config/paths.js";
import { loadGlobalRuntimeDotEnvFiles, loadWorkspaceDotEnvFile } from "../infra/dotenv.js";
export function loadCliDotEnv(opts?: { quiet?: boolean }) {
const quiet = opts?.quiet ?? true;
const cwdEnvPath = path.join(process.cwd(), ".env");
loadWorkspaceDotEnvFile(cwdEnvPath, { quiet });
// Then load the global fallback set without overriding any env vars that
// were already set or loaded from CWD. This includes the Ubuntu fresh-install
// gateway.env compatibility path.
loadGlobalRuntimeDotEnvFiles({
quiet,
stateEnvPath: path.join(resolveStateDir(process.env), ".env"),
});
}