From d6f9bd130fcba843abf75d311fabe977476444b4 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Mon, 20 Apr 2020 11:05:55 -0700 Subject: [PATCH] Fix reshim behavior on gem uninstall and bundle install. --- rubygems-plugin/rubygems_plugin.rb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/rubygems-plugin/rubygems_plugin.rb b/rubygems-plugin/rubygems_plugin.rb index 8e363a3..4b407da 100644 --- a/rubygems-plugin/rubygems_plugin.rb +++ b/rubygems-plugin/rubygems_plugin.rb @@ -1,11 +1,18 @@ -# Yes borrowed from rbenv. Couldn't take my mind off that implementation - -Gem.post_install do |installer| - - if installer.spec.executables.any? && installer.bin_dir == Gem.default_bindir - installer.spec.executables.each do |executable| - `asdf reshim ruby #{RUBY_VERSION} bin/#{executable}` - end +module ReshimInstaller + def install(options) + super + # We don't know which gems were installed, so always reshim. + `asdf reshim ruby` end +end +if defined?(Bundler::Installer) + Bundler::Installer.prepend ReshimInstaller +else + maybe_reshim = lambda do |installer| + # If any gems with executables were installed or uninstalled, reshim. + `asdf reshim ruby` if installer.spec.executables.any? + end + Gem.post_install &maybe_reshim + Gem.post_uninstall &maybe_reshim end -- GitLab