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

Update detect_package_manager to look for new Bun lockfile #530

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

raybrownco
Copy link

@raybrownco raybrownco commented Jan 31, 2025

Description 📖

Update the detect_package_manager method so that it looks for both Bun lockfile formats. Without this change, Bun setups that use the new lockfile format could fail to build, since Vite Ruby would incorrectly think that npm was the desired package manager.

Background 📜

Bun is in the process of switching from the binary bun.lockb file to a new, text-based bun.lock file.

As of Bun 1.2, the new text-based lockfile is the default. We need to update the detect_package_manager to look for both lockfile formats, but we should be able to eventually retire the binary lockfile format.

More info: https://bun.sh/docs/install/lockfile#text-based-lockfile

The Fix 🔨

By looking for the new lockfile format (as well as the old one), the detect_package_manager method will correctly state that Bun is the desired package manager for Bun setups that use the new lockfile format.

Screenshots 📷

Here are excerpts of a failing deploy log:

Installed Bun v1.2.1
Installing dependencies...
bun install v1.2.1 (ce532901)
...
+ [email protected]
+ [email protected]
...
-----> Preparing app for Rails asset pipeline
cp: warning: behavior of -n is non-portable and may change in future; use --update=none instead
       Running: rake assets:precompile
       Building with Vite ⚡️

       rake aborted!
       ViteRuby::MissingExecutableError: ❌ The vite binary is not available. Have you installed the npm packages? (ViteRuby::MissingExecutableError)
       
       Visit the Troubleshooting guide for more information:
         https://vite-ruby.netlify.app/guide/troubleshooting.html#troubleshooting
       
       No such file or directory - npx
       /tmp/build/vendor/bundle/ruby/3.3.0/gems/vite_ruby-3.9.1/lib/vite_ruby/runner.rb:19:in `rescue in run'

This is the first deploy we've attempted since merging a PR that upgraded Bun to use the new lockfile format.

Bun is in the process of switching from the binary `bun.lockb` file to a new, text-based `bun.lock` file. 

As of Bun 1.2, the new text-based lockfile is the default. We need to update the `detect_package_manager` to look for both lockfile formats, but we should be able to eventually retire the binary lockfile format.

More info: https://bun.sh/docs/install/lockfile#text-based-lockfile
@raybrownco raybrownco marked this pull request as ready for review January 31, 2025 16:18
@raybrownco
Copy link
Author

@ElMassimo I didn't see existing specs in place for this method so I didn't add new ones. Let me know if there's anything else you'd like me to add or consider or this PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant