Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from djmarcin/master
Fix auto-reshim on bundle install and gem uninstall.
- Loading branch information
Showing
1 changed file
with
18 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |