diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler.rb | 8 | ||||
-rw-r--r-- | lib/bundler/cli.rb | 2 | ||||
-rw-r--r-- | lib/bundler/fetcher.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/path/installer.rb | 19 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 4 |
5 files changed, 17 insertions, 18 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 38a3de0f..22a35aa9 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -212,13 +212,11 @@ module Bundler end def tmp(name = Process.pid.to_s) - @tmp ||= Pathname.new Dir.mktmpdir("bundler") - @tmp.join(name) + Pathname.new(Dir.mktmpdir(["bundler", name])) end - def cleanup - FileUtils.remove_entry_secure(@tmp) if @tmp - rescue + def rm_rf(path) + FileUtils.remove_entry_secure(path) if path && File.exist?(path) end def settings diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 6a220725..ac193d72 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -11,8 +11,6 @@ module Bundler rescue Exception => e Bundler.ui = UI::Shell.new raise e - ensure - Bundler.cleanup end def initialize(*args) diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 46ac8e44..19225658 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -68,6 +68,8 @@ module Bundler end gem_path + ensure + Bundler.rm_rf(download_path) if Bundler.requires_sudo? end def user_agent diff --git a/lib/bundler/source/path/installer.rb b/lib/bundler/source/path/installer.rb index 6f264489..3b368816 100644 --- a/lib/bundler/source/path/installer.rb +++ b/lib/bundler/source/path/installer.rb @@ -7,31 +7,34 @@ module Bundler def initialize(spec, options = {}) @spec = spec - @tmp_bin_dir = "#{Bundler.tmp(spec.full_name)}/bin" - @gem_bin_dir = "#{Bundler.rubygems.gem_dir}/bin" - @bin_dir = Bundler.requires_sudo? ? @tmp_bin_dir : @gem_bin_dir @gem_dir = Bundler.rubygems.path(spec.full_gem_path) @wrappers = options[:wrappers] || true @env_shebang = options[:env_shebang] || true @format_executable = options[:format_executable] || false @build_args = options[:build_args] || Bundler.rubygems.build_args + @gem_bin_dir = "#{Bundler.rubygems.gem_dir}/bin" + + if Bundler.requires_sudo? + @tmp_dir = Bundler.tmp(spec.full_name).to_s + @bin_dir = "#{@tmp_dir}/bin" + else + @bin_dir = @gem_bin_dir + end end def generate_bin return if spec.executables.nil? || spec.executables.empty? - if Bundler.requires_sudo? - FileUtils.mkdir_p(@tmp_bin_dir) unless File.exist?(@tmp_bin_dir) - end - super if Bundler.requires_sudo? Bundler.mkdir_p @gem_bin_dir spec.executables.each do |exe| - Bundler.sudo "cp -R #{@tmp_bin_dir}/#{exe} #{@gem_bin_dir}" + Bundler.sudo "cp -R #{@bin_dir}/#{exe} #{@gem_bin_dir}" end end + ensure + Bundler.rm_rf(@tmp_dir) if Bundler.requires_sudo? end end diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 925bec66..0112e2be 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -145,9 +145,7 @@ module Bundler spec.loaded_from = loaded_from(spec) ["Installing #{version_message(spec)}", spec.post_install_message] ensure - if install_path && Bundler.requires_sudo? - FileUtils.remove_entry_secure(install_path) - end + Bundler.rm_rf(install_path) if Bundler.requires_sudo? end def cache(spec, custom_path = nil) |