Skip to content

Commit

Permalink
Merge pull request #427 from odilitime/env-change
Browse files Browse the repository at this point in the history
feat: don't require .env to exist
  • Loading branch information
jkbrooks authored Nov 20, 2024
2 parents aa978a7 + c3ab946 commit 9a0e474
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,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.
Expand Down
14 changes: 4 additions & 10 deletions packages/core/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 9a0e474

Please sign in to comment.