diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-26 02:06:00 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-26 02:06:00 +0000 |
commit | 8b424513fd43c398aaeea5dede8bbc5c51602773 (patch) | |
tree | b1509d7a77a52206f7825520c99a693f7818a8a4 /lib/rubygems/installer.rb | |
parent | dbf3fb3d8e6e10e2ac2af19937e0016a4815ca50 (diff) |
Upgrade to RubyGems 1.2.0 r1824. Incorporates [ruby-core:17353].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/installer.rb')
-rw-r--r-- | lib/rubygems/installer.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index ae699a90a0..5e2e8e0f42 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -85,6 +85,32 @@ class Gem::Installer raise Gem::InstallError, "invalid gem format for #{@gem}" end + if not File.writable? @gem_home or + # TODO: Shouldn't have to test for existence of bindir; tests need it. + (@gem_home.to_s == Gem.dir and File.exist? Gem.bindir and + not File.writable? Gem.bindir) + if options[:user_install] == false # You explicitly don't want to use ~ + raise Gem::FilePermissionError, @gem_home + elsif options[:user_install].nil? + say "Warning: falling back to user-level install since #{@gem_home} and #{@bin_dir} aren't both writable." + end + options[:user_install] = true + end + + if options[:user_install] + @gem_home = File.join(ENV['HOME'], '.gem') + + user_bin_dir = File.join(@gem_home, 'gems', 'bin') + if !ENV['PATH'].split(':').include?(user_bin_dir) + say "You don't have #{user_bin_dir} in your PATH." + say "You won't be able to run gem-installed executables until you add it." + end + + Dir.mkdir @gem_home if ! File.directory? @gem_home + # If it's still not writable, you've got issues. + raise Gem::FilePermissionError, @gem_home if ! File.writable? @gem_home + end + @spec = @format.spec @gem_dir = File.join(@gem_home, "gems", @spec.full_name).untaint @@ -132,7 +158,6 @@ class Gem::Installer end FileUtils.mkdir_p @gem_home unless File.directory? @gem_home - raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home Gem.ensure_gem_subdirectories @gem_home @@ -206,6 +231,7 @@ class Gem::Installer file_name = File.join @gem_home, 'specifications', "#{@spec.full_name}.gemspec" + file_name.untaint File.open(file_name, "w") do |file| |