GyulyVGC/sniffnet · error
Could not restore default settings
Error message
Could not restore default settings
What it means
Printed when the `--restore-default` CLI flag is given and `Conf::default().store()` fails (src/cli/mod.rs:66). store() serializes the default configuration via confy to the user's config file; on failure Sniffnet prints this message to stderr and exits with code 1 instead of launching the GUI. The confy error itself is swallowed — only the generic message is shown.
Source
Thrown at src/cli/mod.rs:66
std::process::exit(0);
}
std::process::exit(1);
} else {
// truncate logs file
let _ = std::fs::OpenOptions::new()
.write(true)
.truncate(true)
.open(logs_file)
.log_err(crate::location!());
}
}
if args.restore_default {
if Conf::default().store().is_ok() {
println!("Restored default settings");
std::process::exit(0);
} else {
eprintln!("Could not restore default settings");
std::process::exit(1);
}
}
if args.config_path {
if let Ok(config_path) =
confy::get_configuration_file_path(SNIFFNET_LOWERCASE, Conf::FILE_NAME)
{
println!("{}", config_path.display());
std::process::exit(0);
} else {
eprintln!("Could not retrieve configuration file path");
std::process::exit(1);
}
}
args
}View on GitHub (pinned to 48b0575dc0)
Solutions
- Check and fix ownership/permissions of the config file and its parent directory (e.g. `chown -R $USER ~/.config/sniffnet` on Linux, `chmod u+w` on the file).
- Locate the file with `sniffnet --config-path` (or compute the confy path) and ensure its parent directory exists and is writable.
- Verify HOME / XDG_CONFIG_HOME are set to a writable path in the environment where the command runs.
- If the config is corrupt or unfixable, delete/rename the file and rerun `--restore-default` so a fresh default file is created.
- Free disk space if the write fails due to a full filesystem.
Example fix
// before — failure reason is swallowed
if Conf::default().store().is_ok() {
println!("Restored default settings");
std::process::exit(0);
} else {
eprintln!("Could not restore default settings");
std::process::exit(1);
}
// after — surface the confy error for diagnosis
match Conf::default().store() {
Ok(()) => {
println!("Restored default settings");
std::process::exit(0);
}
Err(e) => {
eprintln!("Could not restore default settings: {e}");
std::process::exit(1);
}
} Defensive patterns
Strategy: validation
Validate before calling
# verify the config file is replaceable before running --restore-default $ cfg=$(sniffnet --config-path 2>/dev/null || echo "$HOME/.config/sniffnet/sniffnet.toml") $ touch "$cfg" 2>/dev/null && echo writable || echo "fix permissions first: chown $USER $(dirname "$cfg")"
Prevention
- Never run Sniffnet's first launch as sudo — it leaves root-owned config files that later break --restore-default for the normal user.
- After any sudo run, `chown -R $USER ~/.config/sniffnet` (or the platform equivalent).
- Keep HOME/XDG_CONFIG_HOME set and writable in the shell/service that runs the binary.
- Test with `sniffnet --config-path && touch $(sniffnet --config-path)` to confirm writability.
When it happens
Trigger: Running `sniffnet --restore-default` when the configuration file path is not writable: confy::store failing because the config directory doesn't exist or can't be created, the file is read-only or owned by another user (e.g. previously created with sudo), the disk is full, or $XDG_CONFIG_HOME/$HOME point to an invalid location.
Common situations: User previously ran Sniffnet with sudo, leaving root-owned config files that the normal user cannot overwrite; HOME or XDG_CONFIG_HOME unset in a minimal/SSH session or in a unit file; a full disk or read-only home (live USB); migrating the config directory between versions while old files remain with wrong permissions.
Related errors
- Could not retrieve configuration file path
- Sniffnet error at [{file}:{line}]: {e}
- panic!() (bare panic triggered by ErrorLogger on Err in debu
- An error occurred!
- No traffic can be observed because the adapter you selected
AI-assisted analysis of GyulyVGC/sniffnet@48b0575dc0 (2026-08-16).
Data as JSON: /api/errors/99467ef790a0677b.
Report an issue: GitHub.