Skip to content

Commit d6f9bd1

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

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

rubygems-plugin/rubygems_plugin.rb

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
# Yes borrowed from rbenv. Couldn't take my mind off that implementation
2-
3-
Gem.post_install do |installer|
4-
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}`
8-
end
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`
96
end
7+
end
108

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+
`asdf reshim ruby` if installer.spec.executables.any?
15+
end
16+
Gem.post_install &maybe_reshim
17+
Gem.post_uninstall &maybe_reshim
1118
end

0 commit comments

Comments
 (0)