2014-10-16 10:33:22 -04:00
|
|
|
hook = lambda do |installer|
|
|
|
|
begin
|
|
|
|
# Ignore gems that aren't installed in locations that rbenv searches for binstubs
|
|
|
|
if installer.spec.executables.any? &&
|
|
|
|
[Gem.default_bindir, Gem.bindir(Gem.user_dir)].include?(installer.bin_dir)
|
2014-10-19 12:06:09 -04:00
|
|
|
`rbenv rehash`
|
2014-10-16 10:33:22 -04:00
|
|
|
end
|
|
|
|
rescue
|
2014-10-19 07:43:29 -04:00
|
|
|
warn "rbenv: error in gem-rehash (#{$!.class.name}: #{$!.message})"
|
2014-10-16 10:33:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-12-09 15:14:40 -05:00
|
|
|
if defined?(Bundler::Installer) &&
|
|
|
|
Bundler::Installer.private_method_defined?(:install) &&
|
|
|
|
!Bundler::Installer.private_method_defined?(:install_without_rbenv_rehash)
|
2014-10-19 07:43:29 -04:00
|
|
|
Bundler::Installer.class_eval do
|
2023-12-09 15:14:40 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
alias install_without_rbenv_rehash install
|
|
|
|
def install(options)
|
|
|
|
begin
|
|
|
|
if Gem.default_path.include?(Bundler.bundle_path.to_s)
|
|
|
|
bin_dir = Gem.bindir(Bundler.bundle_path.to_s)
|
|
|
|
bins_before = File.exist?(bin_dir) ? Dir.entries(bin_dir).size : 2
|
2014-10-19 07:43:29 -04:00
|
|
|
end
|
2023-12-09 15:14:40 -05:00
|
|
|
rescue
|
|
|
|
warn "rbenv: error in Bundler post-install hook (#{$!.class.name}: #{$!.message})"
|
|
|
|
end
|
2015-10-25 13:31:50 -04:00
|
|
|
|
2023-12-09 15:14:40 -05:00
|
|
|
result = install_without_rbenv_rehash(options)
|
2015-10-25 13:31:50 -04:00
|
|
|
|
2023-12-09 15:14:40 -05:00
|
|
|
if bin_dir && File.exist?(bin_dir) && Dir.entries(bin_dir).size > bins_before
|
|
|
|
`rbenv rehash`
|
2014-10-19 07:43:29 -04:00
|
|
|
end
|
2023-12-09 15:14:40 -05:00
|
|
|
result
|
2014-10-19 07:43:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Gem.post_install(&hook)
|
|
|
|
Gem.post_uninstall(&hook)
|
|
|
|
rescue
|
|
|
|
warn "rbenv: error installing gem-rehash hooks (#{$!.class.name}: #{$!.message})"
|
|
|
|
end
|
2014-10-16 10:33:22 -04:00
|
|
|
end
|