{"record":{"id":"b36e9e4345fda45c","repo":"tw93/Pake","slug":"can-t-create-dir-err","errorCode":null,"errorMessage":"Can't create dir {}: {err}","messagePattern":"Can't create dir (.+?): (.+?)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/util.rs","lineNumber":41,"sourceCode":"\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\npub fn read_last_url(path: &Path) -> std::io::Result<Option<tauri::Url>> {\n    match std::fs::read_to_string(path) {\n        Ok(value) => Ok(tauri::Url::parse(&value)\n            .ok()\n            .filter(|url| matches!(url.scheme(), \"http\" | \"https\"))),\n        Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(None),\n        Err(error) => Err(error),\n    }\n}","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/tw93/Pake/blob/c8fe8a3f1a115428e3555c06b3de9b7458aa0d54/src-tauri/src/util.rs#L23-L59","documentation":"get_data_dir joins the package name onto the config dir and creates the directory if missing; create_dir_all failures are rewrapped with this message including the target path. This usually reflects filesystem permission or path problems rather than app logic.","triggerScenarios":"std::fs::create_dir_all(&data_dir) returns Err because a parent is not writable, the path exists as a file, the disk is full, or policy (sandbox/permission) blocks creation.","commonSituations":"Read-only HOME or config filesystem; a file named like the app dir already exists at ~/.config/<package_name>; enterprise-managed machines restricting ~/.config writes.","solutions":["Inspect the path in the message and fix permissions on the parent config directory (chmod/chown).","Remove or rename a non-directory file occupying the target path.","Free disk space or remount the volume read-write, then relaunch."],"exampleFix":"// before\n$ ls ~/.config/pake\n// after\n$ mv ~/.config/pake ~/.config/pake.bak  # if it is a file, then relaunch the app","handlingStrategy":"try-catch","validationCode":"const dir = path.join(os.homedir(), '.config', pkgName);\nif (fs.existsSync(dir) && !fs.statSync(dir).isDirectory()) throw new Error(`${dir} exists and is not a directory`);\nfs.mkdirSync(dir, { recursive: true });","typeGuard":null,"tryCatchPattern":"match std::fs::create_dir_all(&data_dir) { Err(err) => { eprintln!(\"check permissions/occupants of {}: {err}\", data_dir.display()); return Err(...); }, Ok(_) => {} }","preventionTips":["Keep ~/.config (or platform equivalent) writable by the running user","Check for a file collision at the target path before installing","Monitor disk space on the config volume"],"tags":["filesystem","permissions","directory"],"backgroundTag":"mkdir-permission-denied","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"}