While reading through RBENV's rubygems_plugin.rb
file, I encountered the following line of code:
if defined?(Bundler::Installer) && Bundler::Installer.respond_to?(:install) && !Bundler::Installer.respond_to?(:install_without_rbenv_rehash)
Reviewing this line's git history, I saw that the original version of this line was added in this PR from 2015, and its goal was to ensure that rbenv rehash
is only run once, at the end of the gem installation process. The goal of rbenv rehash
, in turn, is to generate shim files inside ~/.rbenv/shims
for any Ruby gem which includes a terminal command.
Based on the original PR and discussion, it appeared that this code would be executed when the bundle install
command is run inside a project which includes a Gemfile. I wanted to step through this process as it happened, to learn more about Bundler, so I did the following:
v3.1.4
) using rbenv install 3.1.4
.rails
gem via gem install rails
.rails new foobar
.gem
except for the first one (gem 'rails', '~> 5.2.8', '>= 5.2.8.1'
) and one that I added (gem 'wisper'
).if
check inside rubygems_plugin.rb
.bundle install
However, I didn't hit my debugger statement. I also tried placing a 2nd debugger statement outside the if
statement and re-running bundle install
, but that debugger was also skipped.
My best guess is that I'm simply doing something wrong and my understanding is off somehow, and that this is preventing me from reaching my debugger statements. Failing that, I also thought there's a (small) chance that:
Can anyone spot where my thinking has gone awry?
It looks like this PR to the Bundler codebase introduced a change, such that Gem.load_env_plugins
was replaced with Gem.load_plugins
. The latter searches for plugins in different directories than the former, which means that RBENV's rubygems_plugins.rb
is no longer found or loaded.
I confirmed this by adding Gem.load_env_plugins
back into the source code of my Bundler installation's lib/bundler/cli/install.rb
file, and re-running bundle install
. This resulted in my successfully hitting the breakpoints I had added to RBENV's rubygems_plugin.rb
file.