{"record":{"id":"8b424ba66de0fd58","repo":"clash-verge-rev/clash-verge-rev","slug":"failed-to-get-the-app-homedirectory","errorCode":null,"errorMessage":"Failed to get the app homedirectory","messagePattern":"Failed to get the app homedirectory","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/utils/dirs.rs","lineNumber":62,"sourceCode":"\n    let flag = PORTABLE_FLAG.get().unwrap_or(&false);\n    if *flag {\n        let app_exe = current_exe()?;\n        let app_exe = dunce::canonicalize(app_exe)?;\n        let app_dir = app_exe\n            .parent()\n            .ok_or_else(|| anyhow::anyhow!(\"failed to get the portable app dir\"))?;\n        return Ok(PathBuf::from(app_dir).join(\".config\").join(APP_ID));\n    }\n\n    // 避免在Handle未初始化时崩溃\n    let app_handle = handle::Handle::app_handle();\n\n    match app_handle.path().data_dir() {\n        Ok(dir) => Ok(dir.join(APP_ID)),\n        Err(e) => {\n            logging!(error, Type::File, \"Failed to get the app home directory: {e}\");\n            Err(anyhow::anyhow!(\"Failed to get the app homedirectory\"))\n        }\n    }\n}\n\npub fn preinit_app_data_dir() -> Result<PathBuf> {\n    if PORTABLE_FLAG.get().copied().unwrap_or(false) {\n        let executable = std::env::current_exe()?;\n        let parent = executable\n            .parent()\n            .ok_or_else(|| anyhow::anyhow!(\"portable executable has no parent directory\"))?;\n        return Ok(parent.join(\".config\").join(APP_ID));\n    }\n\n    #[cfg(target_os = \"macos\")]\n    let root = PathBuf::from(std::env::var_os(\"HOME\").ok_or_else(|| anyhow::anyhow!(\"HOME is unavailable\"))?)\n        .join(\"Library/Application Support\");\n    #[cfg(target_os = \"linux\")]\n    let root = std::env::var_os(\"XDG_DATA_HOME\")","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/clash-verge-rev/clash-verge-rev/blob/5cad0f2799e74b1105e133bcfc2a45f5c1370ef1/src-tauri/src/utils/dirs.rs#L44-L80","documentation":"Error \"Failed to get the app homedirectory\" thrown in clash-verge-rev/clash-verge-rev.","triggerScenarios":"Thrown at src-tauri/src/utils/dirs.rs:62 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"5cad0f2799e74b1105e133bcfc2a45f5c1370ef1","analyzedAt":"2026-08-12T03:25:57.699Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}