Skip to main content

global_config_path

Function global_config_path 

Source
pub fn global_config_path(name: &str) -> Result<Utf8PathBuf, CoreError>
Expand description

Resolve name inside the global configuration directory for cook.

That directory is CONFIG_DIR_ENV (COOK_CONFIG_DIR) when it is set to a non-empty value, and otherwise the platform’s own — ~/.config/cook on Linux, ~/Library/Application Support/cook on macOS, %APPDATA%\cook\config on Windows.

The override is the only portable way to redirect these lookups. The platform directory is resolved by directories, which on Windows asks the Known Folder API and so ignores HOME and XDG_CONFIG_HOME entirely — setting those isolates a test on Unix and silently does nothing on Windows, where a cook server under test would then find the developer’s real session.json and sync database. Tests that spawn cook set COOK_CONFIG_DIR instead.

The path is returned whether or not anything exists there; nothing is created.

§Errors

CoreError::Config if there is no home directory to resolve against, or if the resolved directory — the override included — is not valid UTF-8. Both carry no path, because the failure is that no path could be built.