tonhowtf/omniget · error
Could not determine data directory
Error message
Could not determine data directory
What it means
`download_ytdlp_binary` computes the target file path via `managed_ytdlp_path()`, which returns None when the app cannot resolve its data directory (e.g. no XDG dirs, no home directory, platform API failure). Rather than guessing a location, it fails with "Could not determine data directory". This is an environment-resolution failure, not a network issue.
Solutions
- Ensure HOME is set and points to a writable directory (export HOME=/path in the service/container).
- Set XDG_DATA_HOME explicitly to a writable location.
- Run the app as a user with a proper profile rather than a system/no-login account.
- Inspect `managed_ytdlp_path()`/dirs crate usage to confirm which environment variable is missing and set it.
Example fix
// before (CI/container) cargo test // after export HOME=/tmp && export XDG_DATA_HOME=/tmp/.data cargo test
Defensive patterns
Strategy: validation
Validate before calling
if std::env::var_os("HOME").is_none() && std::env::var_os("XDG_DATA_HOME").is_none() {
return Err("set HOME or XDG_DATA_HOME before running");
} Type guard
fn data_dir_resolvable() -> bool {
std::env::var_os("XDG_DATA_HOME").is_some() || std::env::var_os("HOME").is_some()
} Try / catch
match ensure_ytdlp().await {
Err(e) if e.to_string().contains("Could not determine data directory") => {
// fix environment (HOME/XDG_DATA_HOME) and retry
}
other => other?,
} Prevention
- Always launch the app/service with HOME set.
- Set XDG_DATA_HOME explicitly in containers and CI.
- Avoid running under no-login system accounts without profiles.
When it happens
Trigger: `managed_ytdlp_path()` returns None — typically because the OS data directory (XDG_DATA_HOME / app data dir) cannot be resolved in the current environment.
Common situations: Running in a minimal container/CI with no HOME set; headless Linux without xdg-user-dirs; restricted service accounts; unusual sandboxed environments that block directory APIs.
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
- Could not determine data directory
- Could not determine data directory
- Could not determine data directory
- Proxy must include a scheme, e.g. http://127.0.0.1:7897
- sem pasta de dados
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/89376af03108511e.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/ytdlp.rs:1827
} else {
"yt-dlp"
}
}
fn ytdlp_release_base(channel: YtdlpChannel) -> &'static str {
match channel {
YtdlpChannel::Stable => "https://github.com/yt-dlp/yt-dlp/releases/latest/download",
YtdlpChannel::Nightly => {
"https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/latest/download"
}
}
}
use crate::core::dependencies::integrity;
async fn download_ytdlp_binary() -> anyhow::Result<PathBuf> {
let target =
managed_ytdlp_path().ok_or_else(|| anyhow!("Could not determine data directory"))?;
download_ytdlp_asset(ytdlp_asset_name(), target).await
}
/// O asset `yt-dlp` da release é o zipapp universal (Python ≥ 3.10).
const YTDLP_ZIPAPP_ASSET: &str = "yt-dlp";
async fn download_ytdlp_zipapp() -> anyhow::Result<PathBuf> {
let target =
managed_ytdlp_zipapp_path().ok_or_else(|| anyhow!("Could not determine data directory"))?;
download_ytdlp_asset(YTDLP_ZIPAPP_ASSET, target).await
}
async fn download_ytdlp_asset(asset: &str, target: PathBuf) -> anyhow::Result<PathBuf> {
if let Some(parent) = target.parent() {
std::fs::create_dir_all(parent)?;
}
let channel = ytdlp_channel();View on GitHub (pinned to 8600b91f42)