fix: .env loading path and directory permissions#21
Conversation
- 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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
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>
- 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>


问题总结
问题 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
改动
Note
Low Risk
Small configuration-only change; main risk is unintended behavior change if deployments relied on the previous
.envlookup path.Overview
Fixes environment loading by changing
index.jsto load.envfrom the project’s own directory (./.env) instead of a hardcoded parent path, improving reliability across working directories.Adds a new
.env.examplewith defaultMEMORY_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.