tonhowtf/omniget · error

Could not determine data directory

Error message

Could not determine data directory

What it means

spicetify::install needs a managed data directory to stage the downloaded Spicetify CLI, but managed_dir() (spicetify.rs:26) returned None. managed_dir resolves the app data dir (via directories/Tauri paths), so None means the OS-level data/config directory could not be determined for the current user/platform.

Solutions

  1. Run the app as a normal desktop user with $HOME set and valid XDG env vars
  2. Unset bad XDG_DATA_HOME/XDG_CONFIG_HOME overrides that point to relative paths
  3. Pre-check that the data dir resolves before calling install and show a user-facing setup error
  4. Fall back to a known writable directory if managed_dir() returns None

Example fix

// before
let dir = managed_dir().ok_or_else(|| anyhow!("Could not determine data directory"))?;
// after
let dir = managed_dir().or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".local/share/omniget")))
    .ok_or_else(|| anyhow!("Could not determine data directory"))?;
Defensive patterns

Strategy: fallback

Validate before calling

if managed_dir().is_none() {
    eprintln!("data directory unavailable; check $HOME/XDG env vars");
    return;
}

Try / catch

match install().await {
    Err(e) if e.to_string().contains("data directory") => show_setup_error(e),
    Err(e) => show_generic_error(e),
    Ok(_) => {}
}

Prevention

When it happens

Trigger: Calling install (via the instala_e_le_status Tauri command) on a system where the base directories crate cannot resolve a data_dir — e.g. XDG_DATA_HOME/XDG_CONFIG_HOME pointing to a relative path, or $HOME unset in a headless/service context.

Common situations: Running the app under a systemd service or CI without $HOME set; invalid XDG env vars on Linux; exotic sandboxed environments where the user profile dir is unavailable.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/spicetify.rs:516

#[cfg(unix)]
fn make_executable(path: &Path) {
    use std::os::unix::fs::PermissionsExt;
    let _ = std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755));
}

#[cfg(not(unix))]
fn make_executable(_path: &Path) {}

/// Baixa o último release do CLI para `<app_data>/bin/spicetify-cli/`.
/// A pasta antiga só sai depois que a nova está inteira no disco.
pub async fn install() -> anyhow::Result<PathBuf> {
    if dependencies::is_flatpak() {
        return Err(anyhow!(
            "dentro do Flatpak o Spicetify nao consegue alterar o Spotify do sistema"
        ));
    }
    let suffix = cli_asset_suffix()?;
    let dir = managed_dir().ok_or_else(|| anyhow!("Could not determine data directory"))?;
    let client = github_client()?;
    let asset = latest_asset(&client, CLI_REPO, |n| n.ends_with(suffix)).await?;
    tracing::info!("[spicetify] baixando {} ({})", asset.name, asset.tag);
    let data = download_verified(&client, &asset).await?;

    let staging = dir.with_extension("new");
    let _ = std::fs::remove_dir_all(&staging);
    std::fs::create_dir_all(&staging)?;
    let is_zip = asset.name.ends_with(".zip");
    let staging_clone = staging.clone();
    tokio::task::spawn_blocking(move || {
        if is_zip {
            unpack_zip(&data, &staging_clone)
        } else {
            unpack_tar_gz(&data, &staging_clone)
        }
    })
    .await

View on GitHub (pinned to 8600b91f42)