mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-09 08:11:09 +00:00
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
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
import path from "node:path";
|
||||
import { resolveStateDir } from "../config/paths.js";
|
||||
import { loadRuntimeDotEnvFile, loadWorkspaceDotEnvFile } from "../infra/dotenv.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 from the active state dir without overriding
|
||||
// any env vars that were already set or loaded from CWD.
|
||||
const globalEnvPath = path.join(resolveStateDir(process.env), ".env");
|
||||
loadRuntimeDotEnvFile(globalEnvPath, { 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"),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user