Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Add RubygemsIntegration#preserve_paths to clean up after RG 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed May 24, 2011
1 parent 09b98f7 commit bea72f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
12 changes: 12 additions & 0 deletions lib/bundler/rubygems_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ def bin_path(gem, bin, ver)
Gem.bin_path(gem, bin, ver)
end

def preserve_paths
# this is a no-op outside of Rubygems 1.8
yield
end

def ui=(obj)
Gem::DefaultUserInteraction.ui = obj
end
Expand Down Expand Up @@ -266,6 +271,13 @@ def find_name(name)
Gem::Specification.find_all_by_name name
end

# Rubygems 1.8 changes Gem.dir when you call Gem::Installer#install with
# an :install_path option. I guess this makes sense for them, but we have
# to change it back for our sudo mode to work.
def preserve_paths
old_dir, old_path = gem_dir, gem_path
yield
Gem.use_paths(old_dir, old_path)
end
end

Expand Down
21 changes: 12 additions & 9 deletions lib/bundler/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,18 @@ def install(spec)
Bundler.ui.info "Installing #{spec.name} (#{spec.version}) "
path = cached_gem(spec)

install_path = Bundler.requires_sudo? ? Bundler.tmp : Bundler.rubygems.gem_dir
options = { :install_dir => install_path,
:ignore_dependencies => true,
:wrappers => true,
:env_shebang => true }
options.merge!(:bin_dir => "#{install_path}/bin") unless spec.executables.nil? || spec.executables.empty?

installer = Gem::Installer.new path, options
installer.install
Bundler.rubygems.preserve_paths do

install_path = Bundler.requires_sudo? ? Bundler.tmp : Bundler.rubygems.gem_dir
options = { :install_dir => install_path,
:ignore_dependencies => true,
:wrappers => true,
:env_shebang => true }
options.merge!(:bin_dir => "#{install_path}/bin") unless spec.executables.nil? || spec.executables.empty?

installer = Gem::Installer.new path, options
installer.install
end

# SUDO HAX
if Bundler.requires_sudo?
Expand Down

0 comments on commit bea72f9

Please sign in to comment.