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
|
|
|
|
|
2014-10-19 07:43:29 -04:00
|
|
|
if defined?(Bundler::Installer) && Bundler::Installer.respond_to?(:install)
|
|
|
|
Bundler::Installer.class_eval do
|
|
|
|
class << self
|
|
|
|
alias install_without_rbenv_rehash install
|
|
|
|
def install(root, definition, options = {})
|
|
|
|
begin
|
2015-10-25 13:31:50 -04:00
|
|
|
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
|
|
|
|
rescue
|
|
|
|
warn "rbenv: error in Bundler post-install hook (#{$!.class.name}: #{$!.message})"
|
|
|
|
end
|
2015-10-25 13:31:50 -04:00
|
|
|
|
|
|
|
result = install_without_rbenv_rehash(root, definition, options)
|
|
|
|
|
|
|
|
if bin_dir && File.exist?(bin_dir) && Dir.entries(bin_dir).size > bins_before
|
|
|
|
`rbenv rehash`
|
|
|
|
end
|
2014-10-19 07:43:29 -04:00
|
|
|
result
|
|
|
|
end
|
|
|
|
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
|