@@ -66,8 +66,6 @@ class Gem::Installer
6666
6767 attr_reader :package
6868
69- @path_warning = false
70-
7169 class << self
7270 #
7371 # Changes in rubygems to lazily loading `rubygems/command` (in order to
@@ -86,11 +84,6 @@ def inherited(klass)
8684 super ( klass )
8785 end
8886
89- ##
90- # True if we've warned about PATH not including Gem.bindir
91-
92- attr_accessor :path_warning
93-
9487 ##
9588 # Overrides the executable format.
9689 #
@@ -188,15 +181,6 @@ def initialize(package, options={})
188181 @package . dir_mode = options [ :dir_mode ]
189182 @package . prog_mode = options [ :prog_mode ]
190183 @package . data_mode = options [ :data_mode ]
191-
192- if @gem_home == Gem . user_dir
193- # If we get here, then one of the following likely happened:
194- # - `--user-install` was specified
195- # - `Gem::PathSupport#home` fell back to `Gem.user_dir`
196- # - GEM_HOME was manually set to `Gem.user_dir`
197-
198- check_that_user_bin_dir_is_in_path
199- end
200184 end
201185
202186 ##
@@ -488,11 +472,21 @@ def generate_windows_script(filename, bindir)
488472 end
489473
490474 def generate_bin # :nodoc:
491- return if spec . executables . nil? || spec . executables . empty?
475+ executables = spec . executables
476+ return if executables . nil? || executables . empty?
477+
478+ if @gem_home == Gem . user_dir
479+ # If we get here, then one of the following likely happened:
480+ # - `--user-install` was specified
481+ # - `Gem::PathSupport#home` fell back to `Gem.user_dir`
482+ # - GEM_HOME was manually set to `Gem.user_dir`
483+
484+ check_that_user_bin_dir_is_in_path ( executables )
485+ end
492486
493487 ensure_writable_dir @bin_dir
494488
495- spec . executables . each do |filename |
489+ executables . each do |filename |
496490 bin_path = File . join gem_dir , spec . bindir , filename
497491 next unless File . exist? bin_path
498492
@@ -694,9 +688,7 @@ def process_options # :nodoc:
694688 end
695689 end
696690
697- def check_that_user_bin_dir_is_in_path # :nodoc:
698- return if self . class . path_warning
699-
691+ def check_that_user_bin_dir_is_in_path ( executables ) # :nodoc:
700692 user_bin_dir = @bin_dir || Gem . bindir ( gem_home )
701693 user_bin_dir = user_bin_dir . tr ( File ::ALT_SEPARATOR , File ::SEPARATOR ) if File ::ALT_SEPARATOR
702694
@@ -712,8 +704,7 @@ def check_that_user_bin_dir_is_in_path # :nodoc:
712704
713705 unless path . include? user_bin_dir
714706 unless !Gem . win_platform? && ( path . include? user_bin_dir . sub ( ENV [ "HOME" ] , "~" ) )
715- alert_warning "You don't have #{ user_bin_dir } in your PATH,\n \t gem executables will not run."
716- self . class . path_warning = true
707+ alert_warning "You don't have #{ user_bin_dir } in your PATH,\n \t gem executables (#{ executables . join ( ", " ) } ) will not run."
717708 end
718709 end
719710 end
0 commit comments