Repository navigation
Go API for the resolved cache root and system search dirs (what chtypes where prints) #530
Description
Activity
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.
- It is computed by the very resolution
fetchandchtypes whereuse, so an embedder never mirrors the precedence. The resolution is the explicit directory,CHTYPES_CACHE,XDG_CACHE_HOMEor~/.cache, then the system directories. - In v2 it includes the major's subroot (v2 dev docs: an explicit cache directory from the binding's own option also gets the v2-dev subroot, not only CHTYPES_CACHE #527).
- Go would get something like
CacheRoot(FetchOptions) (string, error)andSearchDirs(FetchOptions) ([]string, error). The other three bindings get the same pair, and the parity gate holds them to one shape.
Where it lands: a 1.x minor for v1, since it's a binding API addition with no ABI change, and the
v2branch for the dev SDK. Scheduled after the current v2 binding conversions merge. Not urgent; the reporter keeps a single local copy until then.- It is computed by the very resolution
Correction to the description:
chtypes whereprints only the resolved cache root, not the system search directories (checked againstcmd/chtypesin 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.Landed in both trees. Neither change is in a published release yet.
- On
mainin fetch: a public API for the resolved cache root and search directories, in all four bindings (#530) #540 (5ecf1c4), it ships in the next 1.x minor. - On
v2in v2: CHTYPES_OFFLINE, the cache-roots API (ported), and three spec prose items (#528, #530, #541, #527) #546 (deee6f2), it ships in the next2.0.0-devpre-release.
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
fetchandchtypes whereuse, and the parity gate checks that the names match across all four.chtypes where --allprints both. Onv2, every path carries thev2-devsubroot (#527).- On
Request. A Go API that returns the cache root and system search directories the SDK resolves.
chtypes wherealready prints them, but the publicchtypespackage exposes nothing. In v1.1.0 the resolution lives in the internalocifetch.CacheRoot, andFetchOptions.SystemDirsis input only.Why an embedder needs it. WaveHouse uses the resolved paths to:
To do that it has to copy the SDK's precedence itself:
CHTYPES_CACHE;XDG_CACHE_HOME, or~/.cache;/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-devsubroot under every root, explicitCacheDirincluded (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)andchtypes.SystemDirs(FetchOptions) []string, or the same on aRegistrymethod. Either should use exactly the resolutionfetchandwhereuse, so an embedder never mirrors it.