Binstub with bundle path configured loads wrong version of Bundler
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 4k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 81
Description
On the latest version of bundler (2.4.18), but I think this applies to all versions, we noticed a bug(?) wherein if you have path configured, a binstub (using require "bundler/setup") boots into the wrong version of Bundler. More specifically, it just uses your system bundler instead of the higher versioned bundler installed (into say, vendor/bundle) and specified by your Gemfile.lock.
We noticed this problem in our Docker image where Ruby 3.2.2 comes with Bundler 2.4.10. We install gems in our docker image to vendor/bundle. If you run bin/rails (or any binstub) and puts Bundler::VERSION inside the process, you'll get 2.4.10 instead of 2.4.18.
This is easily reproducible locally:
bundle install --path vendor/bundlegem uninstall bundler(this is to uninstall the higher version of bundler from your system gems. It should be installed intovendor/bundlealready).bin/rails runner "puts Bundler::VERSION"
I thought that this was by design since I don't even see how we would load Bundler (whichever one is available), then realize that we've installed gems into a custom path, then switch over to the right version of bundler all within the same process. But then I saw @indirect's blog post: Never bundle exec again and thought, maybe this is an oversight.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with bundle install --path vendor/bundle, removal of the higher system Bundler, and bin/rails runner "puts Bundler::VERSION". Start by tracing how the binstub's require "bundler/setup" selects Bundler when gems are installed under vendor/bundle; done means the binstub loads the version specified by Gemfile.lock rather than the system version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100