Hmbown/CodeWhale · warning · std::io::Error

workspace snapshots are disabled for {reason}: {}

Error message

workspace snapshots are disabled for {reason}: {}

What it means

open_or_init_with_cap refuses InvalidInput to create a workspace snapshot repo when the workspace is one Codewhale deliberately will not snapshot: the filesystem root, the user's home directory itself, or a well-known home collection directory (Desktop, Documents, Downloads, Library, Movies, Music, Pictures directly under home). This is a hard safety guard against sweeping an entire disk/home into git; unlike the size cap it has no config override.

Source

Thrown at crates/tui/src/snapshot/repo.rs:238

    }

    /// Variant of [`Self::open_or_init`] that accepts an explicit
    /// workspace-size cap. `cap_bytes = 0` disables the cap entirely
    /// (always snapshot, regardless of size).
    ///
    /// When the workspace exceeds the cap and the side repo hasn't
    /// been initialized yet, returns `Err(InvalidInput)` with a
    /// "workspace too large" reason. Subsequent calls (after the user
    /// shrinks the workspace or raises the cap via config) succeed.
    pub fn open_or_init_with_cap(workspace: &Path, cap_bytes: u64) -> io::Result<Self> {
        let work_tree = workspace
            .canonicalize()
            .unwrap_or_else(|_| workspace.to_path_buf());
        if let Some(reason) = unsafe_workspace_snapshot_reason(
            &work_tree,
            crate::config::effective_home_dir().as_deref(),
        ) {
            return Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                format!(
                    "workspace snapshots are disabled for {reason}: {}",
                    work_tree.display()
                ),
            ));
        }

        let _ = ensure_snapshot_dir(&work_tree)?;
        let git_dir = snapshot_git_dir(&work_tree);

        let needs_init = !git_dir.exists();
        if needs_init {
            // First-init size guard. Skipping this on subsequent opens
            // is intentional: paying a workspace walk on every snapshot
            // would defeat the purpose of the cap, and a workspace
            // that fit on first init is allowed to grow within the
            // existing repo's `MAX_SNAPSHOT_SIZE_MB` budget. Users on

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. cd into the actual project directory and relaunch so the workspace is a normal subdirectory
  2. If you really want that tree snapshotted, point the workspace at a dedicated subdirectory under it (e.g. ~/work/proj, not ~/Documents)
  3. Do not look for a config flag — this refusal is by design (unsafe_workspace_snapshot_reason), not a tunable cap

Example fix

// before
$ codewhale --workspace ~        // Err: workspace snapshots are disabled for home directory

// after
$ codewhale --workspace ~/src/myapp   // normal project dir, snapshots init fine
Defensive patterns

Strategy: validation

Validate before calling

fn snapshot_safe_workspace(ws: &std::path::Path) -> bool {
    let canon = ws.canonicalize().unwrap_or_else(|_| ws.to_path_buf());
    if canon.parent().is_none() { return false; }                       // filesystem root
    if let Ok(home) = std::env::var("HOME") {
        let home = std::path::Path::new(&home).canonicalize().unwrap_or_else(|_| std::path::PathBuf::from(&home));
        if canon == home { return false; }                               // home itself
        if canon.parent() == Some(home.as_path()) {
            if let Some(n) = canon.file_name().and_then(|n| n.to_str()) {
                if matches!(n, "Desktop"|"Documents"|"Downloads"|"Library"|"Movies"|"Music"|"Pictures") {
                    return false;                                        // home collection dir
                }
            }
        }
    }
    true
}

Type guard

fn is_unsafe_workspace_error(e: &std::io::Error) -> bool {
    e.kind() == std::io::ErrorKind::InvalidInput && e.to_string().contains("snapshots are disabled for")
}

Prevention

When it happens

Trigger: Starting Codewhale with workspace canonicalizing to "/", to $HOME, or to $HOME/Documents (or another listed collection dir) while no side snapshot repo exists yet at snapshot_git_dir(work_tree).

Common situations: Launching from a fresh shell still in $HOME without cd into a project; GUI launchers whose default working directory is home; scripts or containers that intentionally run at /; symlinks that canonicalize a project path back into home.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/58110bb665ec5ed8. Report an issue: GitHub.