Skip to content

Go API for the resolved cache root and system search dirs (what chtypes where prints) #530

Description

@EricAndrechek

Request. A Go API that returns the cache root and system search directories the SDK resolves. chtypes where already prints them, but the public chtypes package exposes nothing. In v1.1.0 the resolution lives in the internal ocifetch.CacheRoot, and FetchOptions.SystemDirs is input only.

Why an embedder needs it. WaveHouse uses the resolved paths to:

  • log the cache it uses at startup;
  • refuse an explicitly configured cache directory that doesn't exist (strict mode reads a missing directory as an empty cache);
  • probe whether the cache is writable, since autofetch installs there;
  • name the searched directories in a "no artifact installed" error.

To do that it has to copy the SDK's precedence itself:

  1. the explicit directory;
  2. CHTYPES_CACHE;
  3. XDG_CACHE_HOME, or ~/.cache;
  4. then /usr/local/share/chtypes/<leaf> and /opt/chtypes/<leaf>.

That copy breaks when the layout changes. The 2.0.0-dev SDK adds a v2-dev subroot under every root, explicit CacheDir included (deliberate, #527), and moves the system directories to …/v2-dev. Measured on v2.0.0-dev.0: WaveHouse's copied v1 logic logs the wrong directory, typo-checks and probes the wrong path, and names the v1 system directories in its errors.

Shape, as an example only. chtypes.CacheRoot(FetchOptions) (string, error) and chtypes.SystemDirs(FetchOptions) []string, or the same on a Registry method. Either should use exactly the resolution fetch and where use, so an embedder never mirrors it.

Activity

  1. EricAndrechek commented on Oct 6, 2026

    @EricAndrechek
    MemberAuthor

    Triage: accepted as binding-only work, for all four bindings.

    Plan: a public API in each binding that returns the resolved cache root and the ordered list of directories searched for installed artifacts.

    Where it lands: a 1.x minor for v1, since it's a binding API addition with no ABI change, and the v2 branch for the dev SDK. Scheduled after the current v2 binding conversions merge. Not urgent; the reporter keeps a single local copy until then.

  2. EricAndrechek commented on Oct 7, 2026

    @EricAndrechek
    MemberAuthor

    Correction to the description: chtypes where prints only the resolved cache root, not the system search directories (checked against cmd/chtypes in v1.1.0 and in v2.0.0-dev.0). The system directories aren't available from the CLI or from the Go API today, so the request covers both: the root and the system search directories.

  3. EricAndrechek commented on Oct 7, 2026

    @EricAndrechek
    MemberAuthor

    Landed in both trees. Neither change is in a published release yet.

    Each binding gets a public pair that returns the resolved cache root and the ordered list of system search directories. Both come from the same resolution that fetch and chtypes where use, and the parity gate checks that the names match across all four. chtypes where --all prints both. On v2, every path carries the v2-dev subroot (#527).

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions