{"record":{"id":"e6565722d36fdbec","repo":"tw93/Pake","slug":"failed-to-resolve-config-dir-err","errorCode":null,"errorMessage":"Failed to resolve config dir: {err}","messagePattern":"Failed to resolve config dir: (.+?)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/util.rs","lineNumber":32,"sourceCode":"        serde_json::from_str(include_str!(\"../pake.json\")).expect(\"Failed to parse pake config\");\n\n    #[cfg(feature = \"cli-build\")]\n    let tauri_config: Config = serde_json::from_str(include_str!(\"../.pake/tauri.conf.json\"))\n        .expect(\"Failed to parse tauri config\");\n\n    #[cfg(not(feature = \"cli-build\"))]\n    let tauri_config: Config = serde_json::from_str(include_str!(\"../tauri.conf.json\"))\n        .expect(\"Failed to parse tauri config\");\n\n    (pake_config, tauri_config)\n}\n\npub fn get_data_dir(app: &AppHandle, package_name: String) -> std::io::Result<PathBuf> {\n    let data_dir = app\n        .path()\n        .config_dir()\n        .map_err(|err| {\n            std::io::Error::new(\n                std::io::ErrorKind::NotFound,\n                format!(\"Failed to resolve config dir: {err}\"),\n            )\n        })?\n        .join(package_name);\n\n    if !data_dir.exists() {\n        std::fs::create_dir_all(&data_dir).map_err(|err| {\n            std::io::Error::new(\n                err.kind(),\n                format!(\"Can't create dir {}: {err}\", data_dir.display()),\n            )\n        })?;\n    }\n\n    Ok(data_dir)\n}\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/tw93/Pake/blob/c8fe8a3f1a115428e3555c06b3de9b7458aa0d54/src-tauri/src/util.rs#L14-L50","documentation":"get_data_dir resolves the platform config directory via Tauri's path API; if resolution fails (rare, e.g. no valid base directories on the system) it wraps the tauri::Error into a NotFound io::Error with this message. build_window surfaces it as the app's window-build failure.","triggerScenarios":"app.path().config_dir() returns Err, typically on Linux when XDG base-directory resolution fails or the runtime environment lacks required variables/homedir context.","commonSituations":"Running the binary in a stripped container or systemd service without XDG_CONFIG_HOME and no user record; corrupted environment in CI sandboxes.","solutions":["Launch the app inside a normal desktop session with HOME and XDG_CONFIG_HOME set.","Set XDG_CONFIG_HOME explicitly to a writable directory before launching.","Check the source error in the message for the platform-specific cause and fix that environment issue."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if (!process.env.HOME && !process.env.XDG_CONFIG_HOME && process.platform === 'linux') throw new Error('no config dir base: set XDG_CONFIG_HOME');","typeGuard":null,"tryCatchPattern":"match get_data_dir(app, package_name) { Err(e) => { eprintln!(\"cannot resolve config dir, launch in a desktop session or set XDG_CONFIG_HOME: {e}\"); return Err(e.into()); }, Ok(d) => d }","preventionTips":["Ensure HOME and XDG_CONFIG_HOME are set when launching from services or containers","Avoid running the GUI app as a headless daemon without an environment","Log the inner error of config_dir() to identify the platform cause early"],"tags":["filesystem","environment","linux"],"backgroundTag":"missing-env-var","analyzedSha":"c8fe8a3f1a115428e3555c06b3de9b7458aa0d54","analyzedAt":"2026-09-20T12:02:36.283Z","contentChangedAt":"2026-09-20T12:02:36.283Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}