Skip to content

fix: .env loading path and directory permissions#21

Merged
autogame-17 merged 1 commit intoEvoMap:mainfrom
LKCY33:fix/env-loading-path
Feb 22, 2026
Merged

fix: .env loading path and directory permissions#21
autogame-17 merged 1 commit intoEvoMap:mainfrom
LKCY33:fix/env-loading-path

Conversation

@LKCY33
Copy link
Contributor

@LKCY33 LKCY33 commented Feb 20, 2026

问题总结

问题 1:dotenv 加载路径错误

现象:dotenv 显示 \injecting env (0)\,环境变量没加载成功

原因:代码 \index.js\ 中硬编码了错误的 .env 加载路径,导致在某些工作目录下找不到 .env 文件

修复:修改为从当前目录加载


问题 2:默认路径指向无权限目录

现象:\ENOENT: no such file or directory, open 'C:\Users\memory\evolution\...'\

原因:.env 没加载成功时,环境变量使用默认值,路径指向系统目录导致无权限写入

修复:添加必要的环境变量示例到 .env.example


改动

文件 改动
\index.js\ dotenv 加载路径改为从当前目录 (./.env)
.env.example\ 添加 \MEMORY_DIR\、\EVOLUTION_DIR\ 等环境变量示例

Note

Low Risk
Small configuration-only change; main risk is unintended behavior change if deployments relied on the previous .env lookup path.

Overview
Fixes environment loading by changing index.js to load .env from the project’s own directory (./.env) instead of a hardcoded parent path, improving reliability across working directories.

Adds a new .env.example with default MEMORY_DIR/EVOLUTION_DIR/MEMORY_GRAPH_PATH (and related optional settings) so installations don’t fall back to unwritable system paths when env vars are missing.

Written by Cursor Bugbot for commit 51aa843. This will update automatically on new commits. Configure here.

- Change dotenv loading path from '../../.env' to './.env'
- Add MEMORY_DIR and EVOLUTION_DIR to .env.example
- Add .env.example for environment configuration

Fixes: ENOENT errors when running in custom directories
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

# Memory and Evolution directories
MEMORY_DIR=./memory
EVOLUTION_DIR=./memory/evolution
MEMORY_GRAPH_PATH=./memory/evolution/memory_graph.jsonl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example env uses CWD-relative paths with __dirname-based loading

Low Severity

The .env file is loaded using path.resolve(__dirname, './.env'), which always resolves relative to the module's install location. However, .env.example suggests relative paths like ./memory for MEMORY_DIR, EVOLUTION_DIR, and MEMORY_GRAPH_PATH, which resolve relative to the current working directory (CWD). If a user copies this template and runs the tool from a different directory (e.g., node /path/to/evolver/index.js), the .env will be found but its paths will resolve against the wrong directory — potentially recreating the exact "no such file or directory" problem this PR aims to fix.

Additional Locations (1)

Fix in Cursor Fix in Web

@autogame-17 autogame-17 merged commit 616a569 into EvoMap:main Feb 22, 2026
1 check passed
fmw666 pushed a commit that referenced this pull request Mar 2, 2026
Add LKCY33 (PR #21), hendrixAIDev (PR #68), toller892 (PR #149).
Update onthebigtree, voidborne-d, blackdogcat entries with full contributions.

Co-authored-by: LKCY33 <lkcY33@users.noreply.github.com>
Co-authored-by: Hendrix <hendrix.ai.dev@gmail.com>
Co-authored-by: toller892 <1094086026@qq.com>
Co-authored-by: Yewlne <dev@yewlne.com>
fmw666 pushed a commit that referenced this pull request Mar 11, 2026
- PR #68 (hendrixAIDev): guard performMaintenance with IS_DRY_RUN
- PR #26 (onthebigtree): hash hostname in env fingerprint, portable validation paths
- PR #63 (voidborne-d): add 61 unit tests for core GEP modules
- PR #21 (LKCY33): add dotenv path rewrite for public build
- PR #25 (onthebigtree): already applied (currentSleepMs, matchPatternToSignals, max_files)
- Update public.manifest.json: include test/*.test.js, add index.js dotenv rewrite

Co-authored-by: Cursor <cursoragent@cursor.com>
fmw666 pushed a commit that referenced this pull request Mar 11, 2026
Add LKCY33 (PR #21), hendrixAIDev (PR #68), toller892 (PR #149)
to acknowledgments. Update onthebigtree entry with PR #25/#26
contributions. Sync Chinese README.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants