Merge pull request #806 from sstephenson/bundle-rehash
Avoid running `rbenv rehash` multiple times during `bundle install`
This commit is contained in:
commit
074161f9c1
@ -6,13 +6,38 @@ hook = lambda do |installer|
|
|||||||
`rbenv rehash`
|
`rbenv rehash`
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
warn "rbenv: error in gem-rehash (#{$!})"
|
warn "rbenv: error in gem-rehash (#{$!.class.name}: #{$!.message})"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
if defined?(Bundler::Installer) && Bundler::Installer.respond_to?(:install)
|
||||||
Gem.post_install(&hook)
|
Bundler::Installer.class_eval do
|
||||||
Gem.post_uninstall(&hook)
|
class << self
|
||||||
rescue
|
alias install_without_rbenv_rehash install
|
||||||
warn "rbenv: error installing gem-rehash hooks (#{$!})"
|
def install(root, definition, 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
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
warn "rbenv: error in Bundler post-install hook (#{$!.class.name}: #{$!.message})"
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user