From 53114dd798a7c2851d3e40a1594fb323058d39cb Mon Sep 17 00:00:00 2001 From: David Marcin Date: Thu, 23 Apr 2020 16:31:10 -0700 Subject: [PATCH] Customize gem install and uninstall hooks --- rubygems-plugin/rubygems_plugin.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rubygems-plugin/rubygems_plugin.rb b/rubygems-plugin/rubygems_plugin.rb index 4b407da..e279b15 100644 --- a/rubygems-plugin/rubygems_plugin.rb +++ b/rubygems-plugin/rubygems_plugin.rb @@ -9,10 +9,15 @@ 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. + Gem.post_install do |installer| + # Reshim any (potentially) new executables. + installer.spec.executables.each do |executable| + `asdf reshim ruby #{RUBY_VERSION} bin/#{executable}` + end + end + Gem.post_uninstall do |installer| + # Unfortunately, reshimming just the removed executables or + # ruby version doesn't work as of 2020/04/23. `asdf reshim ruby` if installer.spec.executables.any? end - Gem.post_install &maybe_reshim - Gem.post_uninstall &maybe_reshim end -- GitLab