Skip to content

Commit

Permalink
Merge pull request #162 from djmarcin/master
Browse files Browse the repository at this point in the history
Fix auto-reshim on bundle install and gem uninstall.
  • Loading branch information
Stratus3D committed May 1, 2020
2 parents 5205df8 + 53114dd commit 8cbfdf4
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions 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

0 comments on commit 8cbfdf4

Please sign in to comment.