valeriansaliou/sonic · critical · panic
Cannot find config file at {custom_path:?}
Error message
Cannot find config file at {custom_path:?} What it means
read_config panics when a custom config path was supplied (e.g. via -c/--config) but no file exists at that path. Sonic aborts immediately rather than silently falling back to defaults, because the user explicitly requested that file.
Source
Thrown at server/src/config.rs:124
back_compat::migrate_channel_search(&mut server_config.channel, &mut core_config);
// Validate configuration.
core_config.validate();
Config {
channel: server_config.channel,
server: server_config.server,
sonic: Arc::new(core_config),
}
}
}
pub fn read_config(custom_path: Option<&str>) -> Config {
if let Some(custom_path) = custom_path {
// Abort if the user specified a config path that does not exist.
if !std::path::Path::new(custom_path).exists() {
panic!("Cannot find config file at {custom_path:?}");
}
let path = std::path::absolute(custom_path).unwrap();
tracing::debug!("reading config file: {path:?}");
Config::parse(config::File::from(path).format(config::FileFormat::Toml))
} else {
for path in DEFAULT_CONFIG_FILE_PATHS {
let path = std::path::absolute(path).unwrap();
tracing::debug!("looking for config file at {path:?}");
if path.exists() {
tracing::debug!("reading config file: {path:?}");
return Config::parse(config::File::from(path).format(config::FileFormat::Toml));
}
}
View on GitHub (pinned to e6a72da6a5)
Solutions
- Verify the path exists: ls <path> — fix typos or the working directory
- Pass an absolute path to the config flag
- In containers, ensure the config file is mounted into the image/pod
- Omit the custom path to use the default config lookup
Example fix
// shell // before ./sonic -c ./confg.toml # typo // after ./sonic -c /etc/sonic/config.toml
Defensive patterns
Strategy: validation
Validate before calling
let path = std::path::Path::new(custom_path);
if !path.exists() {
return Err(format!("config file not found: {}", custom_path));
} Prevention
- Use absolute paths in service units/CLI flags
- Mount the config explicitly in containers and verify at entrypoint
- Check working directory when using relative paths
When it happens
Trigger: Calling read_config(Some("path/to/config.toml")) where std::path::Path::new(custom_path).exists() is false — typically from main after CLI parsing.
Common situations: Typo in the --config flag; relative path from a different working directory; config file deleted or not mounted in a container; wrong file extension/location after a packaging change.
Understand the failure class
Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.
Related errors
- write_buffer for kv must not be zero
- flush_after for kv must be strictly lower than inactive_afte
- max_background_jobs makes max_flushes unneeded, don’t config
- consolidate_after for fst must be strictly lower than inacti
- env_var: variable '{key}' is not set
AI-assisted analysis of valeriansaliou/sonic@e6a72da6a5 (2026-09-01).
Data as JSON: /api/errors/08562ae70f88cb27.
Report an issue: GitHub.