diff --git a/rubygems-plugin/rubygems_plugin.rb b/rubygems-plugin/rubygems_plugin.rb index 8e363a3..e279b15 100644 --- a/rubygems-plugin/rubygems_plugin.rb +++ b/rubygems-plugin/rubygems_plugin.rb @@ -1,11 +1,23 @@ -# Yes borrowed from rbenv. Couldn't take my mind off that implementation - -Gem.post_install do |installer| +module ReshimInstaller + def install(options) + super + # We don't know which gems were installed, so always reshim. + `asdf reshim ruby` + end +end - if installer.spec.executables.any? && installer.bin_dir == Gem.default_bindir +if defined?(Bundler::Installer) + Bundler::Installer.prepend ReshimInstaller +else + Gem.post_install do |installer| + # Reshim any (potentially) new executables. installer.spec.executables.each do |executable| - `asdf reshim ruby #{RUBY_VERSION} bin/#{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 end