feat: honor FOREST_PATH env var for data directory#7215
Conversation
Adds a FOREST_PATH environment variable that overrides `client.data_dir` for `forest`, `forest-cli`, `forest-tool` and `forest-wallet`. Precedence is env > config > defaults. The daemon also logs the resolved data directory on startup. Closes ChainSafe#6008
Add a drop guard so the env-override test restores any prior FOREST_PATH value (and runs cleanup on panic) instead of unconditionally unsetting it. Add unit tests covering the empty-string and unset cases of forest_path_from_env.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
WalkthroughIntroduces a ChangesFOREST_PATH environment variable support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@0xDevNinja this is already being resolved via #7200. |
Summary of changes
Reopens the work from #7080, which was closed as stale. Rebased on current
mainand the only review feedback (a CodeRabbit nit) is addressed.Changes introduced in this pull request:
FOREST_PATHenvironment variable that overrides the data directory forforest,forest-cli,forest-toolandforest-wallet.FOREST_PATHwins overclient.data_dirfrom the config file; when unset, behavior is unchanged.forest-wallethonorsFOREST_PATHwhen set, otherwise keeps the existingForest-WalletProjectDirslocation for backwards compatibility.env_variables.mdand aCHANGELOG.mdentry.Reference issue to close (if applicable)
Closes #6008
Other information and links
Mirrors Lotus's
LOTUS_PATHso operators switching between implementations get a consistent escape hatch. The wallet override is intentionally opt-in (no implicit migration of the existingForest-WalletProjectDirslocation).Tests:
read_config_forest_path_env_overrideexercises env-over-config precedence (gated byserial_test::serial). Following the review on #7080, the test now uses a drop guard that restores any pre-existingFOREST_PATHvalue and runs cleanup even on panic, instead of unconditionally unsetting the variable. Addedforest_path_from_env_empty_is_noneandforest_path_from_env_unset_is_noneto cover the empty-string and unset cases.Change checklist
Summary by CodeRabbit
New Features
FOREST_PATHenvironment variable to override the data directory for Forest, Forest CLI, Forest Tool, and Forest Wallet. Takes precedence overclient.data_dirin the config file.Documentation
FOREST_PATHdocumentation.Improvements