Skip to content

The open-source app everyone uses to manage agents at work

fix(server): load .env from cwd as fallback when .paperclip/.env is missing

Matt Van Horn303c00b61b52
diff --git a/server/src/config.ts b/server/src/config.ts
index 983eba221c..0d25172c69 100644
--- a/server/src/config.ts
+++ b/server/src/config.ts
@@ -1,5 +1,6 @@
import { readConfigFile } from "./config-file.js";
import { existsSync } from "node:fs";
+import { resolve } from "node:path";
import { config as loadDotenv } from "dotenv";
import { resolvePaperclipEnvPath } from "./paths.js";
import {
@@ -27,6 +28,11 @@ if (existsSync(PAPERCLIP_ENV_FILE_PATH)) {
loadDotenv({ path: PAPERCLIP_ENV_FILE_PATH, override: false, quiet: true });
}
+const CWD_ENV_PATH = resolve(process.cwd(), ".env");
+if (CWD_ENV_PATH !== PAPERCLIP_ENV_FILE_PATH && existsSync(CWD_ENV_PATH)) {
+ loadDotenv({ path: CWD_ENV_PATH, override: false, quiet: true });
+}
+
type DatabaseMode = "embedded-postgres" | "postgres";
export interface Config {