tonhowtf/omniget · error

não achei a pasta de dados do app

Error message

não achei a pasta de dados do app

What it means

Thrown by `user_file` when `super::tools_dir()` returns None, meaning the library cannot locate the application data directory on this machine. `local_user_id` depends on it to store/read the machine's private key, so SponsorBlock user identification cannot proceed.

Solutions

  1. Ensure the app runs in an environment where the OS data directory is resolvable (HOME set on Linux/macOS, APPDATA on Windows).
  2. Launch through the normal Tauri app entry point so the data-dir context is available instead of calling the core lib standalone.
  3. Set XDG_DATA_HOME/XDG_CONFIG_HOME explicitly in sandboxed or CI environments.
  4. Fix/extend `tools_dir()` to cover the platform or container layout in question.
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure a data dir is available before running
if std::env::var_os("HOME").is_none() && cfg!(target_os = "linux") {
    return Err("HOME not set; app data dir unresolvable".into());
}

Try / catch

match sponsorblock::local_user_id() {
    Ok(id) => use(id),
    Err(e) if e.to_string().contains("pasta de dados") => {
        eprintln!("run inside the app environment or set XDG_DATA_HOME");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `local_user_id()` (or anything that reaches `user_file()`) on a system where the app data dir cannot be resolved — e.g. unset HOME/XDG dirs on Linux, nonstandard packaging sandbox, or the Tauri context not providing a data path.

Common situations: Running the binary headless or in CI without HOME set; Flatpak/Snap sandbox restricting data dirs; running on an OS the tools_dir resolver does not handle; launching outside the normal Tauri app environment.

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/6cafbf1753ee3500. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/sponsorblock.rs:169

pub fn generate_private_id() -> String {
    format!(
        "{}{}",
        uuid::Uuid::new_v4().simple(),
        uuid::Uuid::new_v4().simple()
    )
}

/// SHA-256 da chave privada, só para a UI mostrar um identificador estável
/// sem exibir a chave. O identificador público de verdade é derivado pelo
/// servidor do SponsorBlock, não por aqui.
pub fn public_fingerprint(private: &str) -> String {
    let mut h = Sha256::new();
    h.update(private.as_bytes());
    hex::encode(h.finalize())
}

fn user_file() -> anyhow::Result<std::path::PathBuf> {
    let dir = super::tools_dir().ok_or_else(|| anyhow!("não achei a pasta de dados do app"))?;
    std::fs::create_dir_all(&dir)?;
    Ok(dir.join(USER_FILE))
}

/// A chave privada da máquina, criada na primeira vez e reusada depois.
pub fn local_user_id() -> anyhow::Result<String> {
    let path = user_file()?;
    if let Ok(existing) = std::fs::read_to_string(&path) {
        let existing = existing.trim().to_string();
        if existing.len() >= 30 {
            return Ok(existing);
        }
    }
    let fresh = generate_private_id();
    std::fs::write(&path, fresh.as_bytes())?;
    Ok(fresh)
}

View on GitHub (pinned to 8600b91f42)