oven-sh/bun · error · Error

Lockfile validation failed: unexpected number of package…

Error message

Lockfile validation failed: unexpected number of package fields

What it means

Lockfile validation counted a different number of package fields than the format declares — the record layout doesn't match the expected field count for this lockfile version. It fires during structural validation of package records.

Solutions

  1. Regenerate the lockfile with the current Bun version
  2. Check for lockfiles written by mismatched Bun versions in the team
  3. Restore from version control if suddenly corrupted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/install/error.rs:189 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/d19c37f415bf9c99. Report an issue: GitHub.

Appendix: source

Thrown at src/install/error.rs:189

    #[error("Lockfile is missing data")]
    LockfileIsMissingData,
    #[error("Lockfile is malformed (expected 0 at the end)")]
    LockfileIsMalformedExpected0AtTheEnd,
    #[error("CorruptLockfile")]
    CorruptLockfile,
    #[error("Lockfile is missing resolution data")]
    LockfileIsMissingResolutionData,
    #[error("MissingPackageName")]
    MissingPackageName,
    #[error("GlobError")]
    GlobError,
    #[error("Invalid")]
    Invalid,
    #[error("Lockfile validation failed: list is impossibly long")]
    LockfileValidationFailedListIsImpossiblyLong,
    #[error("Lockfile validation failed: alignment mismatch")]
    LockfileValidationFailedAlignmentMismatch,
    #[error("Lockfile validation failed: unexpected number of package fields")]
    LockfileValidationFailedUnexpectedNumberOfPackageFields,
    #[error("Lockfile validation failed: invalid package list range")]
    LockfileValidationFailedInvalidPackageListRange,
    #[error("Lockfile validation failed: invalid resolution tag")]
    LockfileValidationFailedInvalidResolutionTag,
    #[error("Lockfile validation failed: invalid package meta")]
    LockfileValidationFailedInvalidPackageMeta,
    #[error("Lockfile validation failed: invalid bin tag")]
    LockfileValidationFailedInvalidBinTag,
    #[error("Lockfile validation failed: invalid package scripts")]
    LockfileValidationFailedInvalidPackageScripts,
    #[error("InvalidNPMLockfile")]
    InvalidNPMLockfile,
    #[error("NotSupported")]
    NotSupported,
    #[error("Unexpected")]
    Unexpected,
    #[error("NotSameFileSystem")]

View on GitHub (pinned to 8c5296ac45)