Skip to content

(aws-lambda-nodejs): bun depenedencies fail with error: lockfile had changes, but lockfile is frozen #32906

@blimmer

Description

@blimmer

Describe the bug

When a bun lockfile contains additional entries compared to what's installed in the docker container at bundling time, the bundling fails with this error:

error: lockfile had changes, but lockfile is frozen
note: try re-running without --frozen-lockfile and commit the updated lockfile

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

N/A - this is new behavior I implemented against #31753

Expected Behavior

I expect changes to the lockfile to be allowed and the synth to pass.

Current Behavior

error: lockfile had changes, but lockfile is frozen
note: try re-running without --frozen-lockfile and commit the updated lockfile

Reproduction Steps

See blimmer/cdk-bug-reports#3 for a working repro case.

Possible Solution

We need to not enforce --frozen-lockfile, like we do for other package managers:

case LockFile.YARN:
return new PackageManager({
lockFile: LockFile.YARN,
installCommand: logLevel && logLevel !== LogLevel.INFO ? ['yarn', 'install', '--no-immutable', '--silent'] : ['yarn', 'install', '--no-immutable'],
runCommand: ['yarn', 'run'],
});
case LockFile.PNPM:
return new PackageManager({
lockFile: LockFile.PNPM,
installCommand: logLevel && logLevel !== LogLevel.INFO ? ['pnpm', 'install', '--reporter', 'silent', '--config.node-linker=hoisted', '--config.package-import-method=clone-or-copy', '--no-prefer-frozen-lockfile'] : ['pnpm', 'install', '--config.node-linker=hoisted', '--config.package-import-method=clone-or-copy', '--no-prefer-frozen-lockfile'],
// --config.node-linker=hoisted to create flat node_modules without symlinks
// --config.package-import-method=clone-or-copy to avoid hardlinking packages from the store
// --no-prefer-frozen-lockfile (works the same as yarn's --no-immutable) Disable --frozen-lockfile that is enabled by default in CI environments (https://github.com/pnpm/pnpm/issues/1994).
runCommand: ['pnpm', 'exec'],
argsSeparator: '--',
});

Additional Information/Context

No response

CDK CLI Version

2.175.1

Framework Version

No response

Node.js Version

22 LTS

OS

MacOS

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions