Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

turns out we already have a mkdir_p for sudo

  • Loading branch information...
commit b2a73fd69efa7ecc45f27981eef4880c1a0a606f 1 parent af6badf
@indirect indirect authored
Showing with 14 additions and 7 deletions.
  1. +1 −1  lib/bundler/fetcher.rb
  2. +13 −6 lib/bundler/source.rb
View
2  lib/bundler/fetcher.rb
@@ -32,7 +32,7 @@ def download_gem_from_uri(spec, uri)
Bundler.rubygems.download_gem(spec, uri, download_path)
if Bundler.requires_sudo?
- Bundler.sudo "mkdir -p #{Bundler.rubygems.gem_dir}/cache"
+ Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/cache"
Bundler.sudo "mv #{Bundler.tmp}/cache/#{spec.full_name}.gem #{gem_path}"
end
View
19 lib/bundler/source.rb
@@ -78,15 +78,21 @@ 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
+ if Bundler.requires_sudo?
+ install_path = Bundler.tmp
+ bin_path = install_path.join("bin")
+ else
+ install_path = Bundler.rubygems.gem_dir
+ bin_path = Bundler.system_bindir
+ end
Bundler.rubygems.preserve_paths do
Bundler::GemInstaller.new(path,
- :install_dir => install_path,
+ :install_dir => install_path.to_s,
+ :bin_dir => bin_path.to_s,
:ignore_dependencies => true,
:wrappers => true,
- :env_shebang => true,
- :bin_dir => Bundler.system_bindir
+ :env_shebang => true
).install
end
@@ -96,11 +102,12 @@ def install(spec)
# SUDO HAX
if Bundler.requires_sudo?
- Bundler.sudo "mkdir -p #{Bundler.rubygems.gem_dir}/gems #{Bundler.rubygems.gem_dir}/specifications"
+ Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/gems"
+ Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/specifications"
Bundler.sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Bundler.rubygems.gem_dir}/gems/"
Bundler.sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Bundler.rubygems.gem_dir}/specifications/"
spec.executables.each do |exe|
- Bundler.sudo "mkdir -p #{Bundler.system_bindir}"
+ Bundler.mkdir_p Bundler.system_bindir
Bundler.sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Bundler.system_bindir}"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.