oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
72.1k stars 2.58k forks source link

Migrating package-lock.json with overrides produces bun.lockb without overrrides #7233

Open hborchardt opened 8 months ago

hborchardt commented 8 months ago

What version of Bun is running?

1.0.13+f5bf67bd1

What platform is your computer?

Linux 5.15.0-47-generic x86_64 unknown

What steps can reproduce the bug?

Hi, I want to use bun in our CI to install dependencies based on an existing package-lock.json. My package.json contains overrides, which leads to the following problem:

What is the expected behavior?

No error, as the package.json did not change.

What do you see instead?

error: lockfile had changes, but lockfile is frozen

Additional information

With some debugging I identified that the problem is that during migration, the Lockfile's overrides field is not set. So the following code path is triggered, leading to a difference in lockfiles: https://github.com/oven-sh/bun/blob/778bad9dfd1b093cfd58a41a44ca9106828a9e0f/src/install/lockfile.zig#L2896-L2897 This is probably because the information is not explicitly contained in the package-lock.json file, and the migration only considers the package-lock.json, not the package.json. So my ideas would be:

Jarred-Sumner commented 8 months ago

Thanks for the detailed bug report

Yes this was an oversight. We implemented package-lock.json and then overrides, then didn’t go back and make sure overrides persisted as expected