tonhowtf/omniget · error
Could not determine data directory
Error message
Could not determine data directory
What it means
The pricing module caches the model price table in the platform data directory; cache_path() returns Option and is None when no data directory can be resolved (e.g. no HOME/XDG dir on Linux, missing APPDATA on Windows). load() converts that None into this error before even attempting a fetch. All public entry points (info, search, price_for) go through load, so they all fail in this state.
Solutions
- Set HOME (Linux/macOS) or APPDATA/LOCALAPPDATA (Windows) to a writable directory
- Set an explicit XDG_DATA_HOME to a writable path
- Ensure the process runs as a user with a real profile directory
- Run the app outside restricted service contexts or pass a configured data dir
Example fix
// before: failing under systemd ExecStart=/opt/app/omniget // after Environment=HOME=/var/lib/omniget ExecStart=/opt/app/omniget
Defensive patterns
Strategy: validation
Validate before calling
// check a resolvable data dir before calling the API
let ok = std::env::var("HOME").is_ok()
|| std::env::var("XDG_DATA_HOME").is_ok()
|| std::env::var("APPDATA").is_ok();
if !ok { eprintln!("defina HOME ou XDG_DATA_HOME"); } Prevention
- Always set HOME (or XDG_DATA_HOME) for services, cron jobs and containers
- Run daemons under a real user account with a writable profile
- Document required env vars for headless deployments
When it happens
Trigger: Calling info, search, or price_for on a system where dirs-style data-dir resolution fails: running as a service without HOME set, container images with no user profile, or exotic platforms the directory library doesn't support.
Common situations: CI runners or systemd units running without HOME, Docker containers running as root with no XDG_DATA_HOME, misconfigured environment after su/sudo.
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/d5eff83a62b593e7.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pricing.rs:47
pub supports_tools: bool,
pub supports_reasoning: bool,
pub supports_caching: bool,
pub deprecation_date: Option<String>,
}
fn cache_path() -> Option<PathBuf> {
super::tools_dir().map(|d| d.join("pricing").join("litellm.json"))
}
#[derive(Debug, Clone, Serialize)]
pub struct PricingInfo {
pub models: usize,
pub updated_at: Option<String>,
pub path: Option<String>,
}
async fn load(force: bool) -> anyhow::Result<serde_json::Value> {
let path = cache_path().ok_or_else(|| anyhow!("Could not determine data directory"))?;
let fresh = std::fs::metadata(&path)
.and_then(|m| m.modified())
.map(|t| t.elapsed().map(|e| e < MAX_AGE).unwrap_or(false))
.unwrap_or(false);
if !force && fresh {
if let Ok(text) = tokio::fs::read_to_string(&path).await {
if let Ok(v) = serde_json::from_str(&text) {
return Ok(v);
}
}
}
let client = super::client()?;
match client.get(LITELLM_URL).send().await {
Ok(resp) if resp.status().is_success() => {
let text = resp.text().await?;
let v: serde_json::Value = serde_json::from_str(&text)?;
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent)?;View on GitHub (pinned to 8600b91f42)