{"record":{"id":"4e41f3475dd3c20d","repo":"tonhowtf/omniget","slug":"could-not-determine-data-directory-spicetify","errorCode":null,"errorMessage":"Could not determine data directory","messagePattern":"Could not determine data directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/spicetify.rs","lineNumber":516,"sourceCode":"#[cfg(unix)]\nfn make_executable(path: &Path) {\n    use std::os::unix::fs::PermissionsExt;\n    let _ = std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755));\n}\n\n#[cfg(not(unix))]\nfn make_executable(_path: &Path) {}\n\n/// Baixa o último release do CLI para `<app_data>/bin/spicetify-cli/`.\n/// A pasta antiga só sai depois que a nova está inteira no disco.\npub async fn install() -> anyhow::Result<PathBuf> {\n    if dependencies::is_flatpak() {\n        return Err(anyhow!(\n            \"dentro do Flatpak o Spicetify nao consegue alterar o Spotify do sistema\"\n        ));\n    }\n    let suffix = cli_asset_suffix()?;\n    let dir = managed_dir().ok_or_else(|| anyhow!(\"Could not determine data directory\"))?;\n    let client = github_client()?;\n    let asset = latest_asset(&client, CLI_REPO, |n| n.ends_with(suffix)).await?;\n    tracing::info!(\"[spicetify] baixando {} ({})\", asset.name, asset.tag);\n    let data = download_verified(&client, &asset).await?;\n\n    let staging = dir.with_extension(\"new\");\n    let _ = std::fs::remove_dir_all(&staging);\n    std::fs::create_dir_all(&staging)?;\n    let is_zip = asset.name.ends_with(\".zip\");\n    let staging_clone = staging.clone();\n    tokio::task::spawn_blocking(move || {\n        if is_zip {\n            unpack_zip(&data, &staging_clone)\n        } else {\n            unpack_tar_gz(&data, &staging_clone)\n        }\n    })\n    .await","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/spicetify.rs#L498-L534","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the app as a normal desktop user with $HOME set and valid XDG env vars","Unset bad XDG_DATA_HOME/XDG_CONFIG_HOME overrides that point to relative paths","Pre-check that the data dir resolves before calling install and show a user-facing setup error","Fall back to a known writable directory if managed_dir() returns None"],"exampleFix":"// before\nlet dir = managed_dir().ok_or_else(|| anyhow!(\"Could not determine data directory\"))?;\n// after\nlet dir = managed_dir().or_else(|| std::env::var_os(\"HOME\").map(|h| PathBuf::from(h).join(\".local/share/omniget\")))\n    .ok_or_else(|| anyhow!(\"Could not determine data directory\"))?;","handlingStrategy":"fallback","validationCode":"if managed_dir().is_none() {\n    eprintln!(\"data directory unavailable; check $HOME/XDG env vars\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"match install().await {\n    Err(e) if e.to_string().contains(\"data directory\") => show_setup_error(e),\n    Err(e) => show_generic_error(e),\n    Ok(_) => {}\n}","preventionTips":["Launch the app in a normal desktop session with $HOME set","Avoid relative XDG_* env var overrides","Probe managed_dir()/dirs::data_dir() at startup and disable install features early"],"tags":["filesystem","environment","install"],"backgroundTag":"missing-env-var","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}