pnpm/pnpm · error · TarballError::ReadLocalTarball

local tarball is too large to read into memory ({size} bytes

Error message

local tarball is too large to read into memory ({size} bytes)

What it means

read_local_tarball_buffer pre-reserves size+1 bytes so it can detect a file that grew during the read; the size.checked_add(1) guard fires only when the stat-reported size is u64::MAX, i.e. the incremented bound cannot be represented. The message surfaces this as the tarball being too large to read into memory. It is unreachable for any real archive size - only a filesystem reporting an absurd st_size (broken FUSE/procfs-style mounts) can trip it.

Source

Thrown at pnpm/crates/tarball/src/local_tarball.rs:56

        return Ok(());
    }
    Err(read_local_tarball_error(
        path,
        io::ErrorKind::InvalidInput,
        "local tarball path is not a regular file",
    ))
}

pub(crate) async fn read_local_tarball_buffer(
    file: tokio::fs::File,
    path: &Path,
    package_url: &str,
    size: u64,
) -> Result<Vec<u8>, TarballError> {
    use tokio::io::AsyncReadExt;

    let read_limit = size.checked_add(1).ok_or_else(|| {
        read_local_tarball_error(
            path,
            io::ErrorKind::InvalidData,
            format!("local tarball is too large to read into memory ({size} bytes)"),
        )
    })?;
    let mut buffer = allocate_local_tarball_buffer(path, package_url, size)?;
    let mut reader = file.take(read_limit);
    reader
        .read_to_end(&mut buffer)
        .await
        .map_err(|source| TarballError::ReadLocalTarball { path: path.to_path_buf(), source })?;
    if u64::try_from(buffer.len()).unwrap_or(u64::MAX) > size {
        return Err(read_local_tarball_error(
            path,
            io::ErrorKind::InvalidData,
            format!("local tarball changed while reading; refused to read past {size} bytes"),
        ));
    }

View on GitHub (pinned to 6261b7f388)

Solutions

  1. Check what the path really is: stat the file and confirm a sane size
  2. Copy/recreate the tarball onto a normal filesystem and reference that copy
  3. If a FUSE/network mount reports bogus sizes, read through the mount's own tooling or remount properly
Defensive patterns

Strategy: validation

Validate before calling

fn sane_tarball_size(meta: &std::fs::Metadata) -> bool {
    meta.len() != u64::MAX && usize::try_from(meta.len()).is_ok()
}

Type guard

fn is_size_overflow(err: &TarballError) -> bool {
    matches!(err, TarballError::ReadLocalTarball { source, .. }
        if source.kind() == std::io::ErrorKind::InvalidData
            && source.to_string().contains("too large to read into memory"))
}

Prevention

When it happens

Trigger: A file: dependency whose path stat()s with st_size == u64::MAX - pseudo-filesystems or faulty FUSE mounts reporting junk sizes for regular-looking files.

Common situations: Pointing a file: dependency at a special file on a pseudo-filesystem; container mounts with broken metadata.

Related errors


AI-assisted analysis of pnpm/pnpm@6261b7f388 (2026-08-17). Data as JSON: /api/errors/6e94d300a11b1e28. Report an issue: GitHub.