clash-verge-rev/clash-verge-rev · error · anyhow::Error

Failed to get the app homedirectory

Error message

Failed to get the app homedirectory

What it means

Error "Failed to get the app homedirectory" thrown in clash-verge-rev/clash-verge-rev.

Source

Thrown at src-tauri/src/utils/dirs.rs:62

    let flag = PORTABLE_FLAG.get().unwrap_or(&false);
    if *flag {
        let app_exe = current_exe()?;
        let app_exe = dunce::canonicalize(app_exe)?;
        let app_dir = app_exe
            .parent()
            .ok_or_else(|| anyhow::anyhow!("failed to get the portable app dir"))?;
        return Ok(PathBuf::from(app_dir).join(".config").join(APP_ID));
    }

    // 避免在Handle未初始化时崩溃
    let app_handle = handle::Handle::app_handle();

    match app_handle.path().data_dir() {
        Ok(dir) => Ok(dir.join(APP_ID)),
        Err(e) => {
            logging!(error, Type::File, "Failed to get the app home directory: {e}");
            Err(anyhow::anyhow!("Failed to get the app homedirectory"))
        }
    }
}

pub fn preinit_app_data_dir() -> Result<PathBuf> {
    if PORTABLE_FLAG.get().copied().unwrap_or(false) {
        let executable = std::env::current_exe()?;
        let parent = executable
            .parent()
            .ok_or_else(|| anyhow::anyhow!("portable executable has no parent directory"))?;
        return Ok(parent.join(".config").join(APP_ID));
    }

    #[cfg(target_os = "macos")]
    let root = PathBuf::from(std::env::var_os("HOME").ok_or_else(|| anyhow::anyhow!("HOME is unavailable"))?)
        .join("Library/Application Support");
    #[cfg(target_os = "linux")]
    let root = std::env::var_os("XDG_DATA_HOME")

View on GitHub (pinned to 5cad0f2799)

When it happens

Trigger: Thrown at src-tauri/src/utils/dirs.rs:62 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of clash-verge-rev/clash-verge-rev@5cad0f2799 (2026-08-12). Data as JSON: /api/errors/8b424ba66de0fd58. Report an issue: GitHub.