Skip to content

Two divergent Context implementations: src/lib.rs misses the global aisle/pantry fallback #417

Closed

Description

@dubadub

There are two Context types with the same name and different behaviour, and the tests exercise the one that is wrong.

src/main.rs resolves aisle.conf locally and then falls back to the global config directory:

// src/main.rs
pub fn aisle(&self) -> Option<Utf8PathBuf> {
    let auto = self.base_path.join(LOCAL_CONFIG_DIR).join(AUTO_AISLE);
    auto.is_file().then_some(auto).or_else(|| {
        let global = global_file_path(AUTO_AISLE).ok()?;
        global.is_file().then_some(global)
    })
}

src/lib.rs checks only the local path:

// src/lib.rs
pub fn aisle(&self) -> Option<Utf8PathBuf> {
    let local_config = self.base_path.join("config").join("aisle.conf");
    if local_config.is_file() { Some(local_config) } else { None }
}

pantry() diverges the same way. Documented behaviour (CLAUDE.md) is the main.rs version: ./config/, then ~/.config/cook/ or the platform equivalent.

Why it went unnoticed

The binary uses main.rs's copy, so shipped behaviour is correct. src/lib.rs exists to expose modules to the test suite, so the copy the tests exercise is the one missing the global fallback. Any test written against the lib target silently gets different configuration resolution from the binary it is meant to be testing.

Impact

Latent rather than user-facing today. The risk is that the two drift further, or that a future consumer of the lib target inherits the incomplete lookup.

Notes

Being addressed as part of extracting the commands into a library crate, where both copies are replaced by a single Context with an explicit, opt-in discover(). Filing separately because it is a pre-existing defect on main and worth recording independently of that work.

Activity

  1. added
    help wanted
    on Aug 13, 2026
  2. dubadub commented on Aug 14, 2026

    @dubadub
    MemberAuthor

    Fixed on main by the cookcli-core extraction (#434), rather than by a change filed against this issue.

    There is one Context now. src/lib.rs re-exports core's instead of carrying its own copy, so there is nowhere for the two to drift:

    // src/lib.rs
    pub use cookcli_core::Context;

    The surviving definition is the one with the global fallback — local ./config/, then the platform configuration directory — so the copy the tests exercise and the copy the binary uses are now the same code.

    Verified while clearing the help wanted backlog in #444; no change was needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions