cjpais/Handy · critical

Failed to initialize model manager

Error message

Failed to initialize model manager

What it means

Startup panic when ModelManager::new returns Err. The constructor resolves the app data dir via portable::app_data_dir(app_handle) (mapped to 'Failed to get app data dir: {e}' on failure) and then fs::create_dir_all on <app_data>/models — so real-world failures are path-resolution errors or filesystem errors (permission denied, read-only volume, disk full).

Solutions

  1. Check free space and write permissions on the app data dir (~/Library/Application Support/Handy, %APPDATA%, ~/.local/share)
  2. If portable mode is active, point its data dir at a writable location
  3. Repair ownership/ACLs on the app data directory
  4. Include the underlying error ({e:#}) in the panic message so logs name the failing path

Example fix

// before
let model_manager =
    Arc::new(ModelManager::new(app_handle).expect("Failed to initialize model manager"));

// after — the panic still names the root cause chain
let model_manager = Arc::new(ModelManager::new(app_handle).unwrap_or_else(|e| {
    panic!("Failed to initialize model manager: {e:#}")
}));
Defensive patterns

Strategy: validation

Validate before calling

// Probe the app data dir before heavy init at startup
let models_dir = crate::portable::app_data_dir(app_handle)?.join("models");
std::fs::create_dir_all(&models_dir)?;
let probe = models_dir.join(".write-probe");
std::fs::write(&probe, b"")?;
std::fs::remove_file(&probe)?;

Prevention

When it happens

Trigger: initialize_core_logic at every normal app launch: app_data_dir errors (paths plugin cannot produce a directory) or create_dir_all on the models dir fails.

Common situations: App data dir on a full or read-only disk; ownership/ACL damage after copying data between machines; portable mode pointing at an unwritable path; endpoint protection blocking creation of a models directory.

Related errors


AI-assisted analysis of cjpais/Handy@ba10ce1943 (2026-08-17). Data as JSON: /api/errors/7b9ac41a5f1ff489. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/lib.rs:196

            );
            return true;
        }
    }

    false
}

fn initialize_core_logic(app_handle: &AppHandle) {
    // Note: Enigo (keyboard/mouse simulation) is NOT initialized here.
    // The frontend is responsible for calling the `initialize_enigo` command
    // after onboarding completes. This avoids triggering permission dialogs
    // on macOS before the user is ready.

    // Initialize the managers. The audio recorder receives the streaming router
    // explicitly, so always-on microphone startup can wire live-preview frames
    // even before Tauri state is populated.
    let model_manager =
        Arc::new(ModelManager::new(app_handle).expect("Failed to initialize model manager"));
    let transcription_manager = Arc::new(
        TranscriptionManager::new(app_handle, model_manager.clone())
            .expect("Failed to initialize transcription manager"),
    );
    let recording_manager = Arc::new(
        AudioRecordingManager::new(app_handle, transcription_manager.stream_router())
            .expect("Failed to initialize recording manager"),
    );
    let history_manager =
        Arc::new(HistoryManager::new(app_handle).expect("Failed to initialize history manager"));

    // Initialize the transcribe-cpp native backend (logging + backend module
    // registration) once, before any whisper model is loaded.
    managers::transcription::init_transcribe_backend();

    // Apply accelerator preferences before any model loads
    managers::transcription::apply_accelerator_settings(app_handle);

View on GitHub (pinned to ba10ce1943)