Repository navigation
feat(config): add RLEDGER_CONFIG_DIR and deprecate RLEDGER_CONFIG. - #1795
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
robcohen
left a comment
There was a problem hiding this comment.
Thanks for this — the direction is right (#1616's actual ask was always "relocate my config directory", and the file-level RLEDGER_CONFIG only got half of it), and the test discipline here is exemplary: pure *_with_override helpers for unit coverage, subprocess tests that set env on Command instead of set_var (exactly this repo's hermeticity rule), a wiring test that would catch a typo'd env-var name, the PROGRAMDATA shielding, and the macOS XDG interplay handled and documented. Genuinely nice work.
One premise needs correcting before this can merge, plus red CI:
1. RLEDGER_CONFIG is not "a few days old" — it has shipped in five releases
RLEDGER_CONFIG landed in #1650 on 2026-06-30 and is in v0.17.0 through v0.21.0, including Homebrew builds. And its target audience (chezmoi/home-manager users, per #1616) is exactly the crowd that bakes env vars into dotfile templates and updates them rarely. Making it inert with only a stderr warning silently breaks their config resolution — the warning helps interactive users, but dotfile-managed shells often never surface stderr from a status bar/cron invocation.
Suggested shape (small change to user_config_file_with_override): keep honoring it during the deprecation window —
RLEDGER_CONFIG_DIRset → wins (dir override, both files).- else
RLEDGER_CONFIGset → still honored forconfig.tomlonly (its historical scope), with the deprecation warning you already wrote. - else native + macOS XDG fallback, as in this PR.
If both are set, warn and state that RLEDGER_CONFIG_DIR won. Then the removal "after a few weeks" becomes a release-notes item instead of a silent break. (Deprecation policy nit: weeks-not-releases is hard for downstream packagers — I'd say "removed in the release after next".)
2. CI is red — three checks
- Clippy (×2, both in the new code):
map(<f>).unwrap_or_else(<g>)→map_or_else(inimporters_config_not_found_message), and athis could be a const fn.cargo clippy --all-features --all-targets -- -D warningslocally will show both. - validate-docs: the vitepress build fails on this branch (
build errorin the docs job) — likely a dead link/anchor in the docs edits;cd website && npm run buildreproduces.
Smaller notes (non-blocking)
warn_if_rledger_config_setfires on everyConfig::load()— right call for a deprecation, but with the honor-during-window approach above, only warn when the var is actually used (or superseded), soRLEDGER_CONFIG_DIRadopters don't get a stale warning about a var they've already migrated off.- Heads-up on a benign conflict: open PR #1786 touches
extract_cmdaroundfind_importers_config— whichever lands second needs a trivial rebase. expand_os_path's lossy fallback for non-UTF-8 paths is a reasonable trade and the comment says why — good.
Happy to re-review quickly once the deprecation window + CI are sorted.
|
Update after maintainer review: the hard break of Design-wise this is the right end state: verified that the override reaches every rledger config-dir consumer on main ( What remains before merge is mechanical:
Happy to merge promptly once CI is green. |
Maintainer decision: the RLEDGER_CONFIG hard break is accepted — the deprecation-window request is withdrawn. Remaining asks are in the follow-up comment.
|
Dug into the CI failures — three findings, one of them cryptic enough to save you the decoding:
The branch base is fine (July 13, post-lockfile-fix main) — no rebase needed. |
Maintainer push to unblock rustledger#1795: - clippy: `map_or_else` in importers_config_not_found_message; allow `missing_const_for_fn` on resolve_user_config_path (can't be const on macOS — the XDG fallback queries the filesystem), with a why-comment. - validate-docs: restore the `____`-style thematic rule on the first line of extract.md and configuration.md. The reformat had changed it to `---`, which VitePress reads as a YAML frontmatter opener and then chokes on the `## title:` heading. Verified the real `npx vitepress build docs` now succeeds. - Add deprecated_rledger_config_is_inert_and_warns: a subprocess test pinning the core breaking-change behavior — RLEDGER_CONFIG's config is NOT loaded and the deprecation warning is printed. Nothing tested this before, so a refactor could have silently re-enabled the old var. - Document that the beanquery REPL history/init paths live under the shared `.../beanquery/` dir and are deliberately outside RLEDGER_CONFIG_DIR, so a future relocation pass doesn't move them.
|
Pushed
Design LGTM — unifying the override under one dir is the right end state and I confirmed both Two minor, non-blocking notes for a follow-up (left as-is):
CI should re-run on the new commit. |
Summary
Adds RLEDGER_CONFIG_DIR, an env var that relocates the entire user config directory (both config.toml and importers.toml) to an arbitrary path, replacing the narrower RLEDGER_CONFIG (which only relocated config.toml and never affected importers.toml discovery). This closes the gap where a dotfile manager (chezmoi/home-manager) could only relocate half of rledger's config. In the future when we have more configs like
report.configetc setting the directory once is cleaner. Setting RLEDGER_CONFIG now prints a deprecation warning instead of silently doing nothing. We can remove that after a few weeks to make sure no one else has adopted that feature.Type of Change
I have selected breaking, but it should be okay because the feature that it breaks was only added a few days back and this PR extends that and makes it future proof.
Changes
Testing
cargo testcargo clippypassesChecklist
Review Focus