{"record":{"id":"15db5a97e3b8cc48","repo":"GyulyVGC/sniffnet","slug":"could-not-retrieve-configuration-file-path","errorCode":null,"errorMessage":"Could not retrieve configuration file path","messagePattern":"Could not retrieve configuration file path","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/mod.rs","lineNumber":78,"sourceCode":"\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    }\n\n    pub fn get_boot_task_chain(&self) -> Task<Message> {\n        let mut boot_task_chain = window::latest().map(Message::StartApp);\n        if let Some(adapter) = self.adapter.clone() {\n            boot_task_chain = boot_task_chain\n                .chain(Task::done(Message::SetCaptureSource(\n                    CaptureSourcePicklist::Device,\n                )))\n                .chain(Task::done(Message::DeviceSelection(adapter)))\n                .chain(Task::done(Message::Start));\n        }\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/GyulyVGC/sniffnet/blob/48b0575dc0d3c7e503a466a3cb2c1466ba600f8e/src/cli/mod.rs#L60-L96","documentation":"Printed when `confy::get_configuration_file_path(SNIFFNET_LOWERCASE, Conf::FILE_NAME)` returns Err (src/cli/mod.rs:78) while handling the `--config-path` CLI flag. confy fails here when it cannot determine the user's configuration directory, since resolving the path requires a valid platform config root (HOME / XDG_CONFIG_HOME on Linux, known folders on Windows/macOS). Sniffnet then exits with code 1.","triggerScenarios":"Running `sniffnet --config-path` in an environment where the config directory cannot be resolved or created: unset or empty $HOME and $XDG_CONFIG_HOME on Linux, running from a systemd service/cron without a user environment, a container with no home directory defined, or directories::next config resolution failing on a broken OS profile.","commonSituations":"Scripts or CI containers invoking the binary with a minimal env (`env -i sniffnet --config-path`); cron/systemd jobs lacking HOME; sandboxed environments where the user db doesn't map to a home path; misconfigured XDG_CONFIG_HOME pointing to a non-existent, non-creatable path.","solutions":["Run the command with a normal interactive shell so HOME is set (e.g. `HOME=$HOME sniffnet --config-path`).","Export a valid XDG_CONFIG_HOME (Linux) pointing to an existing writable directory, or ensure $HOME is set and writable.","In services/containers, set `Environment=HOME=/root` (or the user's home) / `USER root` in the unit or Dockerfile.","Confirm the user has a home directory in /etc/passwd (Linux) when running as a service account."],"exampleFix":"# before — fails in env without HOME (container/cron)\n$ sniffnet --config-path\nCould not retrieve configuration file path\n\n# after — provide a resolvable config root\n$ XDG_CONFIG_HOME=/tmp/config HOME=/root sniffnet --config-path\n/tmp/config/sniffnet/sniffnet.toml  # path resolved, exit 0","handlingStrategy":"validation","validationCode":"# confirm the environment can resolve a config dir before invoking the CLI\n[ -n \"$HOME\" ] || export HOME=/tmp/home\nmkdir -p \"$HOME/.config\"\nsniffnet --config-path","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the binary from a normal user shell; for services/containers always set HOME (and optionally XDG_CONFIG_HOME).","In Dockerfiles add `ENV HOME=/root` (or USER with a home) so confy path resolution succeeds.","In systemd units add `Environment=HOME=%h` or specify User= with an existing passwd entry.","Avoid `env -i` wrappers around Sniffnet CLI commands."],"tags":["rust","sniffnet","cli","confy","environment","xdg"],"backgroundTag":null,"analyzedSha":"48b0575dc0d3c7e503a466a3cb2c1466ba600f8e","analyzedAt":"2026-08-16T09:14:10.427Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}