## ensure_config()


Load the config, or write a first one around *seed_root*.


Usage

``` python
ensure_config(seed_root=None)
```


With *seed_root* and no config file yet, the function writes a configuration with the default database path and *seed_root* as the first kernel root, and creates both directories (#48: planetarypy seeds skd's root from its own storage root on first run). An existing configuration is never changed by *seed_root*.

With no file and no *seed_root* there is nothing to write, so [ConfigError](ConfigError.md#spice_kernel_db.ConfigError) names the command that asks, `spice-kernel-db config --setup` (#49). The CLI runs that prompt itself. Nothing in this module prints or prompts: the first-run questions and the `skd config` display belong to the CLI.


## Parameters


`seed_root: str | Path | None = None`  
The first kernel root to write when there is no config file.


## Returns


`Config`  
The configuration read from the file, or the one just written.


## Raises


`ConfigError`  
The file does not parse, or there is no file and no *seed_root*.

`LegacyDatabaseFound`  
There is no file, and a database sits at the pre-0.19 default location.
