summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2024-09-25 16:59:57 +0200
committergit <svn-admin@ruby-lang.org>2024-09-27 16:49:32 +0000
commitd1324170b6c25e893b0dec4d7829e6d561b15cf3 (patch)
treefa5ead2930abf4ae4ba355ee97f2dde2de0718a9 /lib
parentb873787a42e4ec23dab3dbc5dded95c4804472d2 (diff)
[rubygems/rubygems] Warning about PATH in `--user-install` mode is only necessary for gems with executables
https://github.com/rubygems/rubygems/commit/2fe0f452a2
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/installer.rb37
1 files changed, 14 insertions, 23 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 735d30ab9e..21b72973cc 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -66,8 +66,6 @@ class Gem::Installer
attr_reader :package
- @path_warning = false
-
class << self
#
# Changes in rubygems to lazily loading `rubygems/command` (in order to
@@ -87,11 +85,6 @@ class Gem::Installer
end
##
- # True if we've warned about PATH not including Gem.bindir
-
- attr_accessor :path_warning
-
- ##
# Overrides the executable format.
#
# This is a sprintf format with a "%s" which will be replaced with the
@@ -188,15 +181,6 @@ class Gem::Installer
@package.dir_mode = options[:dir_mode]
@package.prog_mode = options[:prog_mode]
@package.data_mode = options[:data_mode]
-
- if @gem_home == Gem.user_dir
- # If we get here, then one of the following likely happened:
- # - `--user-install` was specified
- # - `Gem::PathSupport#home` fell back to `Gem.user_dir`
- # - GEM_HOME was manually set to `Gem.user_dir`
-
- check_that_user_bin_dir_is_in_path
- end
end
##
@@ -488,11 +472,21 @@ class Gem::Installer
end
def generate_bin # :nodoc:
- return if spec.executables.nil? || spec.executables.empty?
+ executables = spec.executables
+ return if executables.nil? || executables.empty?
+
+ if @gem_home == Gem.user_dir
+ # If we get here, then one of the following likely happened:
+ # - `--user-install` was specified
+ # - `Gem::PathSupport#home` fell back to `Gem.user_dir`
+ # - GEM_HOME was manually set to `Gem.user_dir`
+
+ check_that_user_bin_dir_is_in_path(executables)
+ end
ensure_writable_dir @bin_dir
- spec.executables.each do |filename|
+ executables.each do |filename|
bin_path = File.join gem_dir, spec.bindir, filename
next unless File.exist? bin_path
@@ -694,9 +688,7 @@ class Gem::Installer
end
end
- def check_that_user_bin_dir_is_in_path # :nodoc:
- return if self.class.path_warning
-
+ def check_that_user_bin_dir_is_in_path(executables) # :nodoc:
user_bin_dir = @bin_dir || Gem.bindir(gem_home)
user_bin_dir = user_bin_dir.tr(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
@@ -712,8 +704,7 @@ class Gem::Installer
unless path.include? user_bin_dir
unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV["HOME"], "~"))
- alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run."
- self.class.path_warning = true
+ alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables (#{executables.join(", ")}) will not run."
end
end
end