aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-05-18 13:51:37 -0700
committerCarl Lerche <carllerche@mac.com>2010-05-24 11:50:23 -0700
commit32a2eb2699a89eaf98200c7a00ce4def25feca22 (patch)
tree915fecdb85841fc4b0676eda6897a059fa99e731 /lib/bundler
parent86240f59402d308488d3c90b6638da478a2ef921 (diff)
downloadbundler-32a2eb2699a89eaf98200c7a00ce4def25feca22.tar.gz
First pass at getting bundler to play well when $GEM_HOME is owned by root
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/installer.rb1
-rw-r--r--lib/bundler/source.rb28
2 files changed, 25 insertions, 4 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index ef5697e2..99c1581b 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -48,6 +48,7 @@ module Bundler
spec.source.install(spec)
generate_bundler_executable_stubs(spec)
+ FileUtils.rm_rf(Bundler.tmp)
end
lock
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index f63bfe36..ab55fa61 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -68,15 +68,24 @@ module Bundler
return if @installed[spec.full_name]
+ install_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir
+
installer = Gem::Installer.new path,
- :install_dir => Gem.dir,
+ :install_dir => install_path,
:ignore_dependencies => true,
:wrappers => true,
:env_shebang => true,
- :bin_dir => "#{Gem.dir}/bin"
+ :bin_dir => "#{install_path}/bin"
installer.install
+ # SUDO HAX
+ if Bundler.requires_sudo?
+ `sudo mkdir -p #{Gem.dir}/gems #{Gem.dir}/specifications`
+ `sudo mv #{Bundler.tmp}/gems/#{spec.full_name} #{Gem.dir}/gems/`
+ `sudo mv #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Gem.dir}/specifications/`
+ end
+
spec.loaded_from = "#{Gem.dir}/specifications/#{spec.full_name}.gemspec"
end
@@ -184,8 +193,19 @@ module Bundler
def download_gem_from_uri(spec, uri)
spec.fetch_platform
- Gem::RemoteFetcher.fetcher.download(spec, uri, Gem.dir)
- "#{Gem.dir}/cache/#{spec.full_name}.gem"
+
+ download_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir
+ gem_path = "#{Gem.dir}/cache/#{spec.full_name}.gem"
+
+ FileUtils.mkdir_p("#{download_path}/cache")
+ Gem::RemoteFetcher.fetcher.download(spec, uri, download_path)
+
+ if Bundler.requires_sudo?
+ `sudo mkdir -p #{Gem.dir}/cache`
+ `sudo mv #{Bundler.tmp}/cache/#{spec.full_name}.gem #{gem_path}`
+ end
+
+ gem_path
end
end