Repository navigation
fix(cli): resolve config from -b for doctor, pantry and report - #734
Conversation
LeMyst
left a comment
There was a problem hiding this comment.
Thanks. This works: with #733 merged, cook doctor aisle -b ../r, run from a directory whose config/ holds a different aisle.conf, picks up r/config/aisle.conf. A few points:
- Behaviour change worth a release note.
doctor … -b Xandreport -b Xused to read./config/from the current directory; they now useX/config/or the global config. Anyone who keeps config where they run the command and points-belsewhere loses it silently (report's explicit--aisle/--pantrystill override). The comment atsrc/report.rs:88-90documents the old behaviour and needs updating. reportwith a missing-b.reportdeliberately avoided canonicalizing (to_absolute, aroundreport.rs:130). Nowconfigure_contextrejects a non-existent-bup front with "Failed to canonicalize path", which doesn't name the path. Addingwith_context(|| format!("Base path not found: {path}"))inutil/mod.rs:202would fix that for every command.- The pantry arm is redundant. The
Command::Pantryarm (src/main.rs:119) duplicates whatpantry::runalready does (src/pantry.rs:300-307). Top-levelcook pantry -bwas never broken; the issue's "pantry" meansdoctor pantry. One of the two can go. recipehas no-bflag and no aisle/pantry, so nothing is needed there despite the mention in #711.- One central place. Something like
Command::base_path() -> Option<&Utf8Path>inargs.rs, used once byconfigure_context, would replace the per-command plumbing. It would also make #733'sscan_dirchange andpantry.rs:300unnecessary. - Test. An integration test for
doctor aisle -bwith a base config, usingcommon::with_isolated_config, would be cheap to add.
🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst.
50fdacd to
d8b93b2
Compare
|
Reworked around a central
And yes — the behaviour change (CWD |
d8b93b2 to
84f1ad3
Compare
|
Thanks, one
All the earlier points are addressed (the stale comment at
fmt, clippy, 🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst. |
1d34666 to
dfbdd53
Compare
|
Both done on 1d34666 (your run reviewed 84f1ad3, the pre-rebase head):
The two e2e failures on that run (recipe-scaling payload, aisles #→// hide) — the branch's code between 84f1ad3 and this head is unchanged; the delta is the rebase past merged #593/#753 et al. I've pushed the same tree as dfbdd53 to re-run CI and see whether they reproduce. |
|
Thanks, both are in:
The range-diff from 84f1ad3 shows no code change. A quick rerun from an unrelated working directory still has A correction to my last comment: release-please writes only commit subjects into the changelog and release notes. It doesn't copy the body. So the note in the body stays in 🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst. |
configure_context only honoured --base-path for server, shopping-list and build; doctor, pantry and report each kept their own lookup, so -b X still read ./config/ of the working directory (#711). Command::base_path() now names it once and configure_context resolves it for all of them — which also puts a canonical path in ctx, so the doctor subcommands no longer hand core a raw relative -b (#714) and pantry::run's own rebuild goes away. A missing -b now names the path it failed on. Behaviour change: a ./config/ in the working directory no longer wins when -b points at a different collection — the collection's own config/ is read instead. Only aisle.conf and pantry.conf follow -b; session.json and sync.db still come from the global config directory.
dfbdd53 to
b3ffce3
Compare
|
Rebased past #742 as b3ffce3 — the conflict was exactly where you said, And thanks for the release-please correction — subject-only is good to know. The commit subject already describes the behaviour ( |
Closes #711
Closes #714
Summary
configure_contextonly honoured--base-pathforserver,shopping-listandbuild;doctor,pantryandreporteach kepttheir own lookup, so
-b Xstill read./config/of the workingdirectory.
cook doctor aisle -b Xrun elsewhere reported ingredientsagainst the wrong aisle.conf;
pantry -bandreport -bthe same.Command::base_path()inargs.rsnow names the flag once for everycommand and
configure_contextresolves it — canonicalized — intoctx. Becausectx.base_path()is canonical, the doctor subcommands nolonger hand core a raw relative
-b(which is also the #714 fix, sothis supersedes #733's
scan_dir), andpantry::run's ownre-resolution is gone.
A missing
-bis still rejected up front, but now names the path:Base path not found: <path>.cook recipehas no-band no config lookup, so nothing is neededthere.
Test plan
aisle_with_base_path_reads_the_configuration_thereindoctor_characterization_test.rs:doctor aisle -b <base>run from adirectory with no config reads
base/config/aisle.confand finds theingredient covered.
cook doctor validate -b ./reports relative recipe paths;cook doctor aisle -b /missingerrorsBase path not found: /missing;cook pantry -b ./seed listreads the seed pantry.cargo test --all-featuresgreen; fmt + clippy clean.Generated with Devin