Support new bun.lock text lockfile for Bun

Bun now supports a text lockfile named bun.lock in addition to the existing bun.lockb binary file. The new file will become the default in the next minor Bun version, 1.2, so it would be nice if Netlify recognized the new file name.

As far as I can tell, nothing would really have to change in the implementation except the Bun version used (>=1.1.39), since the bun install command itself will give precedence to the text file if it finds both.

Ref Bun's new text-based lockfile | Bun Blog

In order to work around the issue described above, I committed an empty bun.lockb file to my repository. This works because if bun.lock exists, Bun will use that and ignore bun.lockb. Meanwhile, the mere presence of bun.lockb “tricks” Netlify into using Bun.

For what it’s worth, my netlify.toml build.command script does the following:

  1. Upgrades Bun to the latest version
  2. Removes dependencies that were automatically installed with a previous Bun version
  3. Resets to the git HEAD to undo any changes to the lockfile
  4. Installs deps with a frozen lockfile
  5. Runs the actual build steps

It looks something like this:

[build]
command = "bun upgrade && rm -rf node_modules && git reset --hard HEAD && bun install --frozen-lockfile && bun run build"

This was already done 2 weeks ago: fix: detect bun.lock files in addition to bun.lockb files by mrstork · Pull Request #5918 · netlify/build

Hmm. Then I’m curious why this build from 3 days ago failed with an error message about npm: Netlify

This one passed after adding the empty bun.lockb file: Netlify

Hi, sorry for the delay can you provide the name of the site?

Thanks, and no rush. The site is https://react-querybuilder.js.org/ (Netlify overview here) although that address serves the GitHub Pages version. I only use Netlify for deploy previews for now, so for those builds referenced in the post above, the deployment URL is https://deploy-preview-820--react-querybuilder.netlify.app/ because they were triggered by PR #820 on the react-querybuilder repo.

Hi, @jakeboone02. Would you please test using only bun.lock again now? I believe the that while the merge happened back on the 10th, it was not rolled out to production until much more recently. It should work now, though. If not, please let us know.

Same issue just now with a new branch. It tries to install deps using npm, not bun.

Triggering PR is React 19 by jakeboone02 · Pull Request #834 · react-querybuilder/react-querybuilder · GitHub.

Sample from latest deploy log:

5:51:15 PM: npm workspaces detected
5:51:15 PM: Installing npm packages using npm version 10.2.3
5:51:25 PM: Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code: 1
5:51:25 PM: npm ERR! code ERESOLVE
5:51:25 PM: npm ERR! ERESOLVE unable to resolve dependency tree
5:51:25 PM: npm ERR!
5:51:25 PM: npm ERR! While resolving: website@1.0.0
5:51:25 PM: npm ERR! Found: react@19.0.0
5:51:25 PM: npm ERR! node_modules/react
5:51:25 PM: npm ERR!   react@"^19.0.0" from website@1.0.0
5:51:25 PM: npm ERR!   website
5:51:25 PM: npm ERR!     website@1.0.0
5:51:25 PM: npm ERR!     node_modules/website
5:51:25 PM: npm ERR!       workspace website from the root project
5:51:25 PM: npm ERR!

That is weird. I have asked the devs to check.

1 Like

This should now be fixed.

Confirmed it’s working for my latest commit! Thanks!

1 Like