{"record":{"id":"99467ef790a0677b","repo":"GyulyVGC/sniffnet","slug":"could-not-restore-default-settings","errorCode":null,"errorMessage":"Could not restore default settings","messagePattern":"Could not restore default settings","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/mod.rs","lineNumber":66,"sourceCode":"                    std::process::exit(0);\n                }\n                std::process::exit(1);\n            } else {\n                // truncate logs file\n                let _ = std::fs::OpenOptions::new()\n                    .write(true)\n                    .truncate(true)\n                    .open(logs_file)\n                    .log_err(crate::location!());\n            }\n        }\n\n        if args.restore_default {\n            if Conf::default().store().is_ok() {\n                println!(\"Restored default settings\");\n                std::process::exit(0);\n            } else {\n                eprintln!(\"Could not restore default settings\");\n                std::process::exit(1);\n            }\n        }\n\n        if args.config_path {\n            if let Ok(config_path) =\n                confy::get_configuration_file_path(SNIFFNET_LOWERCASE, Conf::FILE_NAME)\n            {\n                println!(\"{}\", config_path.display());\n                std::process::exit(0);\n            } else {\n                eprintln!(\"Could not retrieve configuration file path\");\n                std::process::exit(1);\n            }\n        }\n\n        args\n    }","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/GyulyVGC/sniffnet/blob/48b0575dc0d3c7e503a466a3cb2c1466ba600f8e/src/cli/mod.rs#L48-L84","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before — failure reason is swallowed\nif Conf::default().store().is_ok() {\n    println!(\"Restored default settings\");\n    std::process::exit(0);\n} else {\n    eprintln!(\"Could not restore default settings\");\n    std::process::exit(1);\n}\n\n// after — surface the confy error for diagnosis\nmatch Conf::default().store() {\n    Ok(()) => {\n        println!(\"Restored default settings\");\n        std::process::exit(0);\n    }\n    Err(e) => {\n        eprintln!(\"Could not restore default settings: {e}\");\n        std::process::exit(1);\n    }\n}","handlingStrategy":"validation","validationCode":"# verify the config file is replaceable before running --restore-default\n$ cfg=$(sniffnet --config-path 2>/dev/null || echo \"$HOME/.config/sniffnet/sniffnet.toml\")\n$ touch \"$cfg\" 2>/dev/null && echo writable || echo \"fix permissions first: chown $USER $(dirname \"$cfg\")\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["rust","sniffnet","cli","config","confy","filesystem-permissions"],"backgroundTag":null,"analyzedSha":"48b0575dc0d3c7e503a466a3cb2c1466ba600f8e","analyzedAt":"2026-08-16T09:14:10.427Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}