tonhowtf/omniget · error · anyhow
sem pasta de dados
Error message
sem pasta de dados
What it means
trakt::store persists Trakt credentials to a JSON file under the app data directory, resolved by file(). If file() returns None (no data directory could be determined), store fails with 'sem pasta de dados' before any write is attempted. This is a hard environment prerequisite for saving/disconnecting Trakt credentials.
Solutions
- Ensure HOME (Linux/macOS) is set to a writable directory before launching the app
- On Linux, set XDG_DATA_HOME explicitly to a writable path
- Launch the app normally via the desktop environment so the OS data dir is resolvable
- Create the expected app data directory manually and verify write permissions
Example fix
// before (container) CMD ["./app"] // after ENV HOME=/home/app ENV XDG_DATA_HOME=/home/app/.local/share CMD ["./app"]
Defensive patterns
Strategy: validation
Validate before calling
let data_dir = std::env::var("XDG_DATA_HOME")
.or_else(|_| std::env::var("HOME").map(|h| format!("{h}/.local/share")));
if data_dir.is_err() {
eprintln!("defina HOME ou XDG_DATA_HOME antes de executar");
} Try / catch
match trakt::save_token(&token) {
Err(e) if e.to_string().contains("sem pasta de dados") => {
eprintln!("configure a pasta de dados (HOME/XDG_DATA_HOME) e tente de novo");
}
other => other?,
} Prevention
- Always launch with HOME (and XDG_DATA_HOME on Linux) pointing to a writable directory
- In containers, create and mount a persistent volume for the app data dir
- Test data-dir resolution early at app startup, not at first credential write
When it happens
Trigger: Calling store() (directly or via save_app, save_token, disconnect, forget, run) on a system where the data directory cannot be resolved — e.g. missing XDG_DATA_HOME/HOME on Linux or an unset app-data path in the embedding environment.
Common situations: Running the app in a sandboxed/containerized environment without HOME set; unusual embedded runtime without a configured data dir; custom user setup with no writable home directory.
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
- sem pasta de dados
- Could not determine data directory
- não achei a pasta de dados do app
- Could not determine data directory
- Could not determine data directory
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/9c65fe103e992ed1.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/lists/trakt.rs:92
}
}
}
static LOCK: Mutex<()> = Mutex::new(());
fn file() -> Option<std::path::PathBuf> {
crate::core::tools::tools_dir().map(|d| d.join("lists-trakt.json"))
}
fn load() -> Creds {
file()
.and_then(|p| std::fs::read_to_string(p).ok())
.and_then(|s| serde_json::from_str(&s).ok())
.unwrap_or_default()
}
fn store(c: &Creds) -> Result<()> {
let p = file().ok_or_else(|| anyhow!("sem pasta de dados"))?;
if let Some(parent) = p.parent() {
std::fs::create_dir_all(parent)?;
}
let tmp = p.with_extension("json.tmp");
std::fs::write(&tmp, serde_json::to_string_pretty(c)?)?;
std::fs::rename(&tmp, &p)?;
Ok(())
}
pub fn creds_view() -> CredsView {
let _g = LOCK.lock().unwrap_or_else(|e| e.into_inner());
load().view()
}
/// Grava as credenciais da app do usuário. Campo em branco mantém o que já
/// estava guardado (a UI nunca recebe o segredo de volta para reenviar).
pub fn save_app(client_id: &str, client_secret: &str) -> Result<CredsView> {
let _g = LOCK.lock().unwrap_or_else(|e| e.into_inner());View on GitHub (pinned to 8600b91f42)