Skip to content

Commit d4f59aa

Browse files
committed
Fix reshim behavior on gem uninstall and bundle install.
1 parent f272de2 commit d4f59aa

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

rubygems-plugin/rubygems_plugin.rb

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
# Yes borrowed from rbenv. Couldn't take my mind off that implementation
2-
3-
Gem.post_install do |installer|
1+
module ReshimInstaller
2+
def install(options)
3+
super
4+
# We don't know which gems were installed, so always reshim.
5+
`asdf reshim ruby`
6+
end
7+
end
48

5-
if installer.spec.executables.any? && installer.bin_dir == Gem.default_bindir
6-
installer.spec.executables.each do |executable|
7-
`asdf reshim ruby #{RUBY_VERSION} bin/#{executable}`
9+
if defined?(Bundler::Installer)
10+
Bundler::Installer.prepend ReshimInstaller
11+
else
12+
maybe_reshim = lambda do |installer|
13+
# If any gems with executables were installed or uninstalled, reshim.
14+
if installer.spec.executables.any?
15+
# `asdf reshim ruby`
816
end
917
end
10-
18+
Gem.post_install &maybe_reshim
19+
Gem.post_uninstall &maybe_reshim
1120
end

0 commit comments

Comments
 (0)