diff options
Diffstat (limited to 'lib/rubygems/installer.rb')
-rw-r--r-- | lib/rubygems/installer.rb | 71 |
1 files changed, 11 insertions, 60 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index d6075dd0a2..50f8d20b33 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -5,7 +5,6 @@ #++ require 'fileutils' -require 'pathname' require 'rbconfig' require 'rubygems/format' @@ -58,17 +57,11 @@ class Gem::Installer attr_reader :spec - @home_install_warning = false @path_warning = false class << self ## - # True if we've warned about ~/.gems install - - attr_accessor :home_install_warning - - ## # True if we've warned about PATH not including Gem.bindir attr_accessor :path_warning @@ -112,7 +105,7 @@ class Gem::Installer @env_shebang = options[:env_shebang] @force = options[:force] gem_home = options[:install_dir] - @gem_home = Pathname.new(gem_home).expand_path + @gem_home = File.expand_path(gem_home) @ignore_dependencies = options[:ignore_dependencies] @format_executable = options[:format_executable] @security_policy = options[:security_policy] @@ -127,27 +120,6 @@ class Gem::Installer raise Gem::InstallError, "invalid gem format for #{@gem}" end - begin - FileUtils.mkdir_p @gem_home - rescue Errno::EACCES, Errno::ENOTDIR - # We'll divert to ~/.gems below - 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) then - if options[:user_install] == false then # You don't want to use ~ - raise Gem::FilePermissionError, @gem_home - elsif options[:user_install].nil? then - unless self.class.home_install_warning or options[:unpack] then - alert_warning "Installing to ~/.gem since #{@gem_home} and\n\t #{Gem.bindir} aren't both writable." - self.class.home_install_warning = true - end - end - options[:user_install] = true - end - if options[:user_install] and not options[:unpack] then @gem_home = Gem.user_dir @@ -158,12 +130,11 @@ class Gem::Installer self.class.path_warning = true end end - - FileUtils.mkdir_p @gem_home unless File.directory? @gem_home - # If it's still not writable, you've got issues. - raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home end + FileUtils.mkdir_p @gem_home + raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home + @spec = @format.spec @gem_dir = File.join(@gem_home, "gems", @spec.full_name).untaint @@ -189,14 +160,15 @@ class Gem::Installer unless @force then if rrv = @spec.required_ruby_version then unless rrv.satisfied_by? Gem.ruby_version then - raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}" + raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}." end end if rrgv = @spec.required_rubygems_version then unless rrgv.satisfied_by? Gem::Version.new(Gem::RubyGemsVersion) then raise Gem::InstallError, - "#{@spec.name} requires RubyGems version #{rrgv}" + "#{@spec.name} requires RubyGems version #{rrgv}. " + + "Try 'gem update --system' to update RubyGems itself." end end @@ -235,8 +207,7 @@ class Gem::Installer say @spec.post_install_message unless @spec.post_install_message.nil? - @spec.loaded_from = File.join(@gem_home, 'specifications', - "#{@spec.full_name}.gemspec") + @spec.loaded_from = File.join(@gem_home, 'specifications', @spec.spec_name) @source_index.add_spec @spec @@ -268,7 +239,7 @@ class Gem::Installer # True if the gems in the source_index satisfy +dependency+. def installation_satisfies_dependency?(dependency) - @source_index.find_name(dependency.name, dependency.version_requirements).size > 0 + @source_index.find_name(dependency.name, dependency.requirement).size > 0 end ## @@ -287,8 +258,7 @@ class Gem::Installer def write_spec rubycode = @spec.to_ruby - file_name = File.join @gem_home, 'specifications', - "#{@spec.full_name}.gemspec" + file_name = File.join @gem_home, 'specifications', @spec.spec_name file_name.untaint @@ -522,7 +492,7 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')} # Ensures that files can't be installed outside the gem directory. def extract_files - expand_and_validate_gem_dir + @gem_dir = File.expand_path @gem_dir raise ArgumentError, "format required to extract from" if @format.nil? @@ -566,24 +536,5 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')} end end - private - - ## - # HACK Pathname is broken on windows. - - def absolute_path? pathname - pathname.absolute? or (Gem.win_platform? and pathname.to_s =~ /\A[a-z]:/i) - end - - def expand_and_validate_gem_dir - @gem_dir = Pathname.new(@gem_dir).expand_path - - unless absolute_path?(@gem_dir) then # HACK is this possible after #expand_path? - raise ArgumentError, "install directory %p not absolute" % @gem_dir - end - - @gem_dir = @gem_dir.to_s - end - end |