New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix auto-reshim on bundle install and gem uninstall. #162
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not specify the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand why the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this is a bug with asdf itself, but while the With version:
Without version:
Although, since installs are likely more frequent than uninstalls, I could change the behavior to iterate over the binaries on install, and just reshim everything on uninstall. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added the customized behavior for install & uninstall. |
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is defined, wouldn't we still want the
Gem
hooks setup too? It doesn't seem like these two things are mutually exclusive.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that
Bundler::Installer
is only defined when thebundle
command is running. While Bundler is operating, we wouldn't want the gem hooks to run because we want to batch one reshim operation at the end rather than after each Gem.