Hmbown/CodeWhale · error

bundle exceeds the file limit

Error message

bundle exceeds the {MAX_BUNDLE_FILES} file limit

What it means

Bundles are capped at `MAX_BUNDLE_FILES` entries. While recursively copying regular files, `copy_bundle_regular_files` increments a shared budget; when the file count exceeds the cap it bails immediately (byte-size overflow raises `OversizedBundle` separately).

Solutions

  1. Reduce the bundle contents: install a curated directory containing only the plugin's needed files
  2. Add excludes when packaging (e.g. skip `node_modules`, `target`, `.git`) so the file count drops under the limit
  3. Split very large plugins into multiple smaller bundles

Example fix

// before: installing the whole repo including node_modules
/plugin install ~/projects/myplugin
// after: package only dist
cd ~/projects/myplugin && tar -czf /tmp/myplugin.tar.gz -C dist .
/plugin install /tmp/myplugin.tar.gz
Defensive patterns

Strategy: validation

Validate before calling

let file_count = walk(source_dir)
    .filter(|p| p.is_file())
    .count();
if file_count > MAX_BUNDLE_FILES {
    eprintln!("bundle has {file_count} files; trim to under the limit");
    return;
}

Try / catch

match install(path) {
    Err(e) if e.to_string().contains("file limit") => {
        eprintln!("too many files; exclude build/vendor dirs and retry");
    }
    Err(e) if e.to_string().contains("OversizedBundle") => {
        eprintln!("bundle too large in bytes; trim contents");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Installing a local bundle (via `stage_local_copy`) that contains more files than `MAX_BUNDLE_FILES`, including files nested in subdirectories — the recursion calls itself, so the count accumulates across the whole tree.

Common situations: Pointing `/plugin install` at a whole repo or `node_modules`-style tree instead of a trimmed bundle directory; a build dir with generated artifacts included; vendored dependencies shipped in the bundle.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/aa1ad9a6edb87c15. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/plugins/install/stage.rs:165

        let entry = entry?;
        let path = entry.path();
        let metadata = fs::symlink_metadata(&path)?;
        if metadata.file_type().is_symlink() {
            return Err(PluginInstallError::SymlinkRejected.into());
        }
        let name = entry.file_name();
        if name == std::ffi::OsStr::new(INSTALLED_FROM_MARKER) {
            continue;
        }
        let target = dest.join(&name);
        if metadata.is_dir() {
            fs::create_dir(&target)
                .with_context(|| format!("failed to create {}", target.display()))?;
            copy_bundle_regular_files(&path, &target, max_size, budget)?;
        } else if metadata.is_file() {
            budget.files = budget.files.saturating_add(1);
            if budget.files > MAX_BUNDLE_FILES {
                bail!("bundle exceeds the {MAX_BUNDLE_FILES} file limit");
            }
            budget.bytes = budget.bytes.saturating_add(metadata.len());
            if budget.bytes > max_size {
                return Err(PluginInstallError::OversizedBundle { limit: max_size }.into());
            }
            fs::copy(&path, &target).with_context(|| {
                format!("failed to copy {} to {}", path.display(), target.display())
            })?;
        }
    }
    Ok(())
}

View on GitHub (pinned to 73e0f67d83)