Zackriya-Solutions/meetily · critical

failed to get app data dir

Error message

failed to get app data dir

What it means

Tauri 2's path().app_data_dir() returns Result<PathBuf, tauri::Error>; it errors when the app identifier is missing/invalid (the data dir is derived from it) or the platform base directory cannot be resolved (e.g. no HOME on Linux). The .expect panics DatabaseManager creation during startup, aborting launch.

Source

Thrown at frontend/src-tauri/src/database/manager.rs:49

        }

        let pool = SqlitePool::connect(tauri_db_path).await?;

        sqlx::migrate!("./migrations").run(&pool).await?;

        Ok(DatabaseManager { pool })
    }

    // NOTE: So for the first time users they needs to start the application
    // after they can just delete the existing .sqlite file and then copy the existing .db file to
    // the current app dir, So the system detects legacy db and copy it and starts with that data
    // (Newly created .sqlite with the copied content from .db)
    pub async fn new_from_app_handle(app_handle: &tauri::AppHandle) -> Result<Self> {
        // Resolve the app's data directory
        let app_data_dir = app_handle
            .path()
            .app_data_dir()
            .expect("failed to get app data dir");
        if !app_data_dir.exists() {
            fs::create_dir_all(&app_data_dir).map_err(|e| sqlx::Error::Io(e))?;
        }

        // Define database paths
        let tauri_db_path = app_data_dir
            .join("meeting_minutes.sqlite")
            .to_string_lossy()
            .to_string();
        // Legacy backend DB path (for auto-migration if exists)
        let backend_db_path = app_data_dir
            .join("meeting_minutes.db")
            .to_string_lossy()
            .to_string();

        // WAL file paths for defensive cleanup
        let wal_path = app_data_dir.join("meeting_minutes.sqlite-wal");
        let shm_path = app_data_dir.join("meeting_minutes.sqlite-shm");

View on GitHub (pinned to 0281737d87)

Solutions

  1. Set a valid identifier in tauri.conf.json, e.g. "identifier": "com.meetily.app" (letters, digits, hyphens, dots only — no underscores)
  2. Replace .expect with proper ? propagation and show the underlying tauri::Error in a startup dialog
  3. Ensure the process has a resolvable home dir (export HOME on Linux service/CI runs)
  4. After fixing config, rebuild so tauri's generate_context! re-embeds the corrected identifier

Example fix

// before
let app_data_dir = app_handle.path().app_data_dir()
    .expect("failed to get app data dir");

// after
let app_data_dir = app_handle.path().app_data_dir()
    .map_err(|e| anyhow::anyhow!("app_data_dir unresolved: {e}"))?;
Defensive patterns

Strategy: validation

Validate before calling

// before app start, confirm the identifier resolves
let dir = app.path().app_data_dir();
if dir.is_err() {
    eprintln!("tauri.conf.json: set a valid `identifier` (e.g. com.meetily.app)");
}

Try / catch

let app_data_dir = app_handle
    .path()
    .app_data_dir()
    .map_err(|e| anyhow::anyhow!("app_data_dir unresolved: {e}"))?;

Prevention

When it happens

Trigger: tauri.conf.json has no valid `identifier` (unset, default placeholder, or contains invalid characters like underscores), or the process runs in an environment without a home/profile directory (system services, minimal CI containers).

Common situations: Developers stripping down tauri.conf.json, copying config templates that omit the identifier, running the built binary from a systemd service or CI sandbox where HOME is unset, renaming the bundle identifier with characters Tauri rejects.

Related errors


AI-assisted analysis of Zackriya-Solutions/meetily@0281737d87 (2026-08-16). Data as JSON: /api/errors/cca9a2ad344e05c2. Report an issue: GitHub.