Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't save lockfile if --frozen-lockfile or --no-save #17481

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

pikdum
Copy link
Contributor

@pikdum pikdum commented Feb 20, 2025

What does this PR do?

When running bun install --frozen-lockfile against a project with a package.json and package-lock.json, this brings back behavior of not creating a bun.lock file. (Regression?)

This also gives bun install --no-save the same behavior. (Not sure if it ever worked when migrating.)

Closes #16646
Closes #16965

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

$ bun install --frozen-lockfile &> /dev/null && ls bun.lock && rm -f bun.lock
bun.lock
$ bun-debug install --frozen-lockfile &> /dev/null && ls bun.lock
ls: cannot access 'bun.lock': No such file or directory

Added some automated tests, too:

$ bun run test 16646

And verified that the tests fail against current main.

@pikdum pikdum changed the title fix: don't save lockfile if --no-save fix: don't save lockfile if --frozen-lockfile Feb 20, 2025
@pikdum pikdum marked this pull request as ready for review February 20, 2025 07:54
@@ -15439,6 +15439,9 @@ pub const PackageManager = struct {
packages_len_before_install: usize,
log_level: Options.LogLevel,
) OOM!void {
if (!this.options.do.save_lockfile) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check for this flag before calling this function. The bug exists in the long chain of or's and and's used to create should_save_lockfile. this.options.do.save_lockfile is already checked, so likely it's not checked early enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved there: eb649a4

Copy link
Member

@dylan-conway dylan-conway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@pikdum pikdum changed the title fix: don't save lockfile if --frozen-lockfile fix: don't save lockfile if --frozen-lockfile or --no-save Feb 21, 2025
@pikdum pikdum requested a review from dylan-conway February 21, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants