From 8962b656ad5d588e755a61320e135ab757b8cc67 Mon Sep 17 00:00:00 2001 From: odilitime Date: Wed, 20 Nov 2024 02:37:21 +0000 Subject: [PATCH 1/2] don't require .env to exist --- packages/core/src/settings.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/core/src/settings.ts b/packages/core/src/settings.ts index 9de8564cb..92bdc049a 100644 --- a/packages/core/src/settings.ts +++ b/packages/core/src/settings.ts @@ -69,18 +69,12 @@ export function loadEnvConfig(): Settings { // Node.js environment: load from .env file const envPath = findNearestEnvFile(); - if (!envPath) { - throw new Error("No .env file found in current or parent directories."); - } - - // Load the .env file - const result = config({ path: envPath }); + // attempt to Load the .env file into process.env + const result = config(envPath ? { path: envPath } : {}); - if (result.error) { - throw new Error(`Error loading .env file: ${result.error}`); + if (!result.error) { + console.log(`Loaded .env file from: ${envPath}`); } - - console.log(`Loaded .env file from: ${envPath}`); return process.env as Settings; } From c3ab9463c1f0629ae36e0f2c9161b17aee8c4d39 Mon Sep 17 00:00:00 2001 From: odilitime Date: Wed, 20 Nov 2024 03:14:01 +0000 Subject: [PATCH 2/2] add note about .env being optional --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 95bd57f67..646cb0eb2 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,14 @@ ### Edit the .env file -Copy .env.example to .env and fill in the appropriate values +Copy .env.example to .env and fill in the appropriate values. ``` cp .env.example .env ``` +Note: .env is optional. If your planning to run multiple distinct agents, you can pass secrets through the character JSON + ### Automatically Start Eliza This will run everything to setup the project and start the bot with the default character.