rubygems-update 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CONTRIBUTING +14 -2
  5. data/History.txt +63 -0
  6. data/Rakefile +68 -91
  7. data/lib/rubygems.rb +5 -3
  8. data/lib/rubygems/command_manager.rb +1 -0
  9. data/lib/rubygems/commands/contents_command.rb +23 -2
  10. data/lib/rubygems/commands/install_command.rb +8 -0
  11. data/lib/rubygems/commands/open_command.rb +1 -8
  12. data/lib/rubygems/commands/uninstall_command.rb +9 -1
  13. data/lib/rubygems/commands/update_command.rb +1 -1
  14. data/lib/rubygems/core_ext/kernel_gem.rb +8 -1
  15. data/lib/rubygems/core_ext/kernel_require.rb +12 -22
  16. data/lib/rubygems/defaults.rb +17 -5
  17. data/lib/rubygems/dependency.rb +7 -1
  18. data/lib/rubygems/dependency_installer.rb +3 -0
  19. data/lib/rubygems/ext/ext_conf_builder.rb +13 -11
  20. data/lib/rubygems/install_update_options.rb +13 -0
  21. data/lib/rubygems/installer.rb +36 -20
  22. data/lib/rubygems/installer_test_case.rb +2 -0
  23. data/lib/rubygems/local_remote_options.rb +1 -1
  24. data/lib/rubygems/name_tuple.rb +1 -1
  25. data/lib/rubygems/request_set.rb +14 -3
  26. data/lib/rubygems/request_set/gem_dependency_api.rb +12 -0
  27. data/lib/rubygems/request_set/lockfile.rb +3 -1
  28. data/lib/rubygems/resolver.rb +15 -0
  29. data/lib/rubygems/resolver/best_set.rb +28 -0
  30. data/lib/rubygems/resolver/conflict.rb +45 -7
  31. data/lib/rubygems/resolver/git_specification.rb +24 -0
  32. data/lib/rubygems/resolver/lock_specification.rb +22 -0
  33. data/lib/rubygems/source.rb +2 -0
  34. data/lib/rubygems/source/git.rb +1 -1
  35. data/lib/rubygems/source/installed.rb +2 -1
  36. data/lib/rubygems/specification.rb +16 -15
  37. data/lib/rubygems/test_case.rb +9 -5
  38. data/test/rubygems/test_gem.rb +72 -2
  39. data/test/rubygems/test_gem_commands_contents_command.rb +46 -3
  40. data/test/rubygems/test_gem_commands_install_command.rb +32 -0
  41. data/test/rubygems/test_gem_commands_uninstall_command.rb +18 -0
  42. data/test/rubygems/test_gem_dependency.rb +23 -0
  43. data/test/rubygems/test_gem_dependency_installer.rb +17 -0
  44. data/test/rubygems/test_gem_ext_builder.rb +12 -1
  45. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +2 -2
  46. data/test/rubygems/test_gem_impossible_dependencies_error.rb +24 -8
  47. data/test/rubygems/test_gem_install_update_options.rb +16 -0
  48. data/test/rubygems/test_gem_installer.rb +52 -0
  49. data/test/rubygems/test_gem_local_remote_options.rb +13 -0
  50. data/test/rubygems/test_gem_package.rb +3 -1
  51. data/test/rubygems/test_gem_package_tar_header.rb +2 -0
  52. data/test/rubygems/test_gem_package_tar_reader.rb +11 -1
  53. data/test/rubygems/test_gem_package_tar_reader_entry.rb +17 -2
  54. data/test/rubygems/test_gem_package_tar_writer.rb +1 -0
  55. data/test/rubygems/test_gem_remote_fetcher.rb +24 -0
  56. data/test/rubygems/test_gem_request_set.rb +74 -4
  57. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +9 -1
  58. data/test/rubygems/test_gem_request_set_lockfile.rb +3 -1
  59. data/test/rubygems/test_gem_requirement.rb +8 -0
  60. data/test/rubygems/test_gem_resolver.rb +39 -0
  61. data/test/rubygems/test_gem_resolver_best_set.rb +57 -0
  62. data/test/rubygems/test_gem_resolver_conflict.rb +22 -10
  63. data/test/rubygems/test_gem_resolver_git_specification.rb +12 -0
  64. data/test/rubygems/test_gem_source_git.rb +6 -2
  65. data/test/rubygems/test_gem_source_installed.rb +8 -0
  66. data/test/rubygems/test_gem_source_lock.rb +2 -2
  67. data/test/rubygems/test_gem_source_vendor.rb +4 -0
  68. data/test/rubygems/test_kernel.rb +6 -0
  69. data/test/rubygems/test_require.rb +60 -0
  70. metadata +5 -5
  71. metadata.gz.sig +0 -0
@@ -61,14 +61,7 @@ class Gem::Commands::OpenCommand < Gem::Command
61
61
  end
62
62
 
63
63
  def open_editor path
64
- Dir.chdir(path) do
65
- pid = fork do
66
- args = (@editor.split(/\s+/) + [path]).join(' ')
67
- exec(args)
68
- end
69
-
70
- Process.detach pid
71
- end
64
+ system(*@editor.split(/\s+/) + [path])
72
65
  end
73
66
 
74
67
  def spec_for name
@@ -15,7 +15,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
15
15
  def initialize
16
16
  super 'uninstall', 'Uninstall gems from the local repository',
17
17
  :version => Gem::Requirement.default, :user_install => true,
18
- :check_dev => false
18
+ :check_dev => false, :vendor => false
19
19
 
20
20
  add_option('-a', '--[no-]all',
21
21
  'Uninstall all matching versions'
@@ -76,6 +76,14 @@ class Gem::Commands::UninstallCommand < Gem::Command
76
76
 
77
77
  add_version_option
78
78
  add_platform_option
79
+
80
+ add_option('--vendor',
81
+ 'Uninstall gem from the vendor directory.',
82
+ 'Only for use by gem repackagers.') do |value, options|
83
+ alert_warning 'Use your OS package manager to uninstall vendor gems'
84
+ options[:vendor] = true
85
+ options[:install_dir] = Gem.vendor_dir
86
+ end
79
87
  end
80
88
 
81
89
  def arguments # :nodoc:
@@ -56,7 +56,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
56
56
  <<-EOF
57
57
  The update command will update your gems to the latest version.
58
58
 
59
- The update comamnd does not remove the previous version. Use the cleanup
59
+ The update command does not remove the previous version. Use the cleanup
60
60
  command to remove old versions.
61
61
  EOF
62
62
  end
@@ -26,6 +26,11 @@ module Kernel
26
26
  # Kernel#gem should be called *before* any require statements (otherwise
27
27
  # RubyGems may load a conflicting library version).
28
28
  #
29
+ # Kernel#gem only loads prerelease versions when prerelease +requirements+
30
+ # are given:
31
+ #
32
+ # gem 'rake', '>= 1.1.a', '< 2'
33
+ #
29
34
  # In older RubyGems versions, the environment variable GEM_SKIP could be
30
35
  # used to skip activation of specified gems, for example to test out changes
31
36
  # that haven't been installed yet. Now RubyGems defers to -I and the
@@ -51,7 +56,9 @@ module Kernel
51
56
  end
52
57
 
53
58
  spec = Gem::Dependency.new(gem_name, *requirements).to_spec
54
- spec.activate if spec
59
+ Gem::LOADED_SPECS_MUTEX.synchronize {
60
+ spec.activate
61
+ } if spec
55
62
  end
56
63
 
57
64
  private :gem
@@ -50,12 +50,8 @@ module Kernel
50
50
  # normal require handle loading a gem from the rescue below.
51
51
 
52
52
  if Gem::Specification.unresolved_deps.empty? then
53
- begin
54
- RUBYGEMS_ACTIVATION_MONITOR.exit
55
- return gem_original_require(path)
56
- ensure
57
- RUBYGEMS_ACTIVATION_MONITOR.enter
58
- end
53
+ RUBYGEMS_ACTIVATION_MONITOR.exit
54
+ return gem_original_require(path)
59
55
  end
60
56
 
61
57
  # If +path+ is for a gem that has already been loaded, don't
@@ -71,8 +67,6 @@ module Kernel
71
67
  begin
72
68
  RUBYGEMS_ACTIVATION_MONITOR.exit
73
69
  return gem_original_require(path)
74
- ensure
75
- RUBYGEMS_ACTIVATION_MONITOR.enter
76
70
  end if spec
77
71
 
78
72
  # Attempt to find +path+ in any unresolved gems...
@@ -105,6 +99,7 @@ module Kernel
105
99
  names = found_specs.map(&:name).uniq
106
100
 
107
101
  if names.size > 1 then
102
+ RUBYGEMS_ACTIVATION_MONITOR.exit
108
103
  raise Gem::LoadError, "#{path} found in multiple gems: #{names.join ', '}"
109
104
  end
110
105
 
@@ -115,32 +110,27 @@ module Kernel
115
110
  unless valid then
116
111
  le = Gem::LoadError.new "unable to find a version of '#{names.first}' to activate"
117
112
  le.name = names.first
113
+ RUBYGEMS_ACTIVATION_MONITOR.exit
118
114
  raise le
119
115
  end
120
116
 
121
117
  valid.activate
122
118
  end
123
119
 
124
- begin
125
- RUBYGEMS_ACTIVATION_MONITOR.exit
126
- return gem_original_require(path)
127
- ensure
128
- RUBYGEMS_ACTIVATION_MONITOR.enter
129
- end
120
+ RUBYGEMS_ACTIVATION_MONITOR.exit
121
+ return gem_original_require(path)
130
122
  rescue LoadError => load_error
123
+ RUBYGEMS_ACTIVATION_MONITOR.enter
124
+
131
125
  if load_error.message.start_with?("Could not find") or
132
126
  (load_error.message.end_with?(path) and Gem.try_activate(path)) then
133
- begin
134
- RUBYGEMS_ACTIVATION_MONITOR.exit
135
- return gem_original_require(path)
136
- ensure
137
- RUBYGEMS_ACTIVATION_MONITOR.enter
138
- end
127
+ RUBYGEMS_ACTIVATION_MONITOR.exit
128
+ return gem_original_require(path)
129
+ else
130
+ RUBYGEMS_ACTIVATION_MONITOR.exit
139
131
  end
140
132
 
141
133
  raise load_error
142
- ensure
143
- RUBYGEMS_ACTIVATION_MONITOR.exit
144
134
  end
145
135
 
146
136
  private :require
@@ -89,11 +89,11 @@ module Gem
89
89
  # Default gem load path
90
90
 
91
91
  def self.default_path
92
- if Gem.user_home && File.exist?(Gem.user_home) then
93
- [user_dir, default_dir]
94
- else
95
- [default_dir]
96
- end
92
+ path = []
93
+ path << user_dir if user_home && File.exist?(user_home)
94
+ path << default_dir
95
+ path << vendor_dir if File.directory? vendor_dir
96
+ path
97
97
  end
98
98
 
99
99
  ##
@@ -160,4 +160,16 @@ module Gem
160
160
  true
161
161
  end
162
162
 
163
+ ##
164
+ # Directory where vendor gems are installed.
165
+
166
+ def self.vendor_dir # :nodoc:
167
+ if vendor_dir = ENV['GEM_VENDOR'] then
168
+ return vendor_dir.dup
169
+ end
170
+
171
+ File.join RbConfig::CONFIG['vendordir'], 'gems',
172
+ RbConfig::CONFIG['ruby_version']
173
+ end
174
+
163
175
  end
@@ -321,6 +321,12 @@ class Gem::Dependency
321
321
  def to_spec
322
322
  matches = self.to_specs
323
323
 
324
- matches.find { |spec| spec.activated? } or matches.last
324
+ active = matches.find { |spec| spec.activated? }
325
+
326
+ return active if active
327
+
328
+ matches.delete_if { |spec| spec.version.prerelease? } unless prerelease?
329
+
330
+ matches.last
325
331
  end
326
332
  end
@@ -72,6 +72,7 @@ class Gem::DependencyInstaller
72
72
  def initialize options = {}
73
73
  @only_install_dir = !!options[:install_dir]
74
74
  @install_dir = options[:install_dir] || Gem.dir
75
+ @build_root = options[:build_root]
75
76
 
76
77
  options = DEFAULT_OPTIONS.merge options
77
78
 
@@ -376,6 +377,7 @@ class Gem::DependencyInstaller
376
377
  options = {
377
378
  :bin_dir => @bin_dir,
378
379
  :build_args => @build_args,
380
+ :document => @document,
379
381
  :env_shebang => @env_shebang,
380
382
  :force => @force,
381
383
  :format_executable => @format_executable,
@@ -383,6 +385,7 @@ class Gem::DependencyInstaller
383
385
  :security_policy => @security_policy,
384
386
  :user_install => @user_install,
385
387
  :wrappers => @wrappers,
388
+ :build_root => @build_root,
386
389
  :install_as_default => @install_as_default
387
390
  }
388
391
  options[:install_dir] = @install_dir if @only_install_dir
@@ -11,13 +11,15 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
11
11
  FileEntry = FileUtils::Entry_ # :nodoc:
12
12
 
13
13
  def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil)
14
- tmp_dest = Dir.mktmpdir(".gem.", ".")
14
+ # relative path required as some versions of mktmpdir return an absolute
15
+ # path which breaks make if it includes a space in the name
16
+ tmp_dest = get_relative_path(Dir.mktmpdir(".gem.", "."))
15
17
 
16
18
  t = nil
17
19
  Tempfile.open %w"siteconf .rb", "." do |siteconf|
18
20
  t = siteconf
19
21
  siteconf.puts "require 'rbconfig'"
20
- siteconf.puts "dest_path = #{(tmp_dest || dest_path).dump}"
22
+ siteconf.puts "dest_path = #{tmp_dest.dump}"
21
23
  %w[sitearchdir sitelibdir].each do |dir|
22
24
  siteconf.puts "RbConfig::MAKEFILE_CONFIG['#{dir}'] = dest_path"
23
25
  siteconf.puts "RbConfig::CONFIG['#{dir}'] = dest_path"
@@ -25,24 +27,19 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
25
27
 
26
28
  siteconf.flush
27
29
 
28
- siteconf_path = File.expand_path siteconf.path
29
-
30
- rubyopt = ENV["RUBYOPT"]
31
30
  destdir = ENV["DESTDIR"]
32
31
 
33
32
  begin
34
- ENV["RUBYOPT"] = ["-r#{siteconf_path}", rubyopt].compact.join(' ')
35
- cmd = [Gem.ruby, File.basename(extension), *args].join ' '
33
+ cmd = [Gem.ruby, "-r", get_relative_path(siteconf.path), File.basename(extension), *args].join ' '
36
34
 
37
35
  begin
38
36
  run cmd, results
39
37
  ensure
40
38
  FileUtils.mv 'mkmf.log', dest_path if File.exist? 'mkmf.log'
39
+ siteconf.unlink
41
40
  end
42
41
 
43
42
  ENV["DESTDIR"] = nil
44
- ENV["RUBYOPT"] = rubyopt
45
- siteconf.unlink
46
43
 
47
44
  make dest_path, results
48
45
 
@@ -57,11 +54,10 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
57
54
 
58
55
  FileEntry.new(tmp_dest).traverse do |ent|
59
56
  destent = ent.class.new(dest_path, ent.rel)
60
- destent.exist? or File.rename(ent.path, destent.path)
57
+ destent.exist? or FileUtils.mv(ent.path, destent.path)
61
58
  end
62
59
  end
63
60
  ensure
64
- ENV["RUBYOPT"] = rubyopt
65
61
  ENV["DESTDIR"] = destdir
66
62
  end
67
63
  end
@@ -72,5 +68,11 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
72
68
  FileUtils.rm_rf tmp_dest if tmp_dest
73
69
  end
74
70
 
71
+ private
72
+ def self.get_relative_path(path)
73
+ path[0..Dir.pwd.length-1] = '.' if path.start_with?(Dir.pwd)
74
+ path
75
+ end
76
+
75
77
  end
76
78
 
@@ -59,6 +59,19 @@ module Gem::InstallUpdateOptions
59
59
  end
60
60
  end
61
61
 
62
+ add_option(:"Install/Update", '--build-root DIR',
63
+ 'Temporary installation root. Useful for building',
64
+ 'packages. Do not use this when installing remote gems.') do |value, options|
65
+ options[:build_root] = File.expand_path(value)
66
+ end
67
+
68
+ add_option(:"Install/Update", '--vendor',
69
+ 'Install gem into the vendor directory.',
70
+ 'Only for use by gem repackagers.') do |value, options|
71
+ options[:vendor] = true
72
+ options[:install_dir] = Gem.vendor_dir
73
+ end
74
+
62
75
  add_option(:"Install/Update", '-N', '--no-document',
63
76
  'Disable documentation generation') do |value, options|
64
77
  options[:document] = []
@@ -39,7 +39,9 @@ class Gem::Installer
39
39
 
40
40
  include Gem::UserInteraction
41
41
 
42
- # DOC: Missing docs or :nodoc:.
42
+ ##
43
+ # Filename of the gem being installed.
44
+
43
45
  attr_reader :gem
44
46
 
45
47
  ##
@@ -47,6 +49,8 @@ class Gem::Installer
47
49
 
48
50
  attr_reader :bin_dir
49
51
 
52
+ attr_reader :build_root # :nodoc:
53
+
50
54
  ##
51
55
  # The gem repository the gem will be installed into
52
56
 
@@ -71,7 +75,13 @@ class Gem::Installer
71
75
 
72
76
  attr_accessor :path_warning
73
77
 
74
- # DOC: Missing docs or :nodoc:.
78
+ ##
79
+ # Overrides the executable format.
80
+ #
81
+ # This is a sprintf format with a "%s" which will be replaced with the
82
+ # executable name. It is based off the ruby executable name's difference
83
+ # from "ruby".
84
+
75
85
  attr_writer :exec_format
76
86
 
77
87
  # Defaults to use Ruby's program prefix and suffix.
@@ -386,8 +396,7 @@ class Gem::Installer
386
396
  end
387
397
  end
388
398
 
389
- # DOC: Missing docs or :nodoc:.
390
- def generate_bin
399
+ def generate_bin # :nodoc:
391
400
  return if spec.executables.nil? or spec.executables.empty?
392
401
 
393
402
  Dir.mkdir @bin_dir unless File.exist? @bin_dir
@@ -536,8 +545,7 @@ class Gem::Installer
536
545
  end
537
546
  end
538
547
 
539
- # DOC: Missing docs or :nodoc:.
540
- def ensure_required_ruby_version_met
548
+ def ensure_required_ruby_version_met # :nodoc:
541
549
  if rrv = spec.required_ruby_version then
542
550
  unless rrv.satisfied_by? Gem.ruby_version then
543
551
  raise Gem::InstallError, "#{spec.name} requires Ruby version #{rrv}."
@@ -545,8 +553,7 @@ class Gem::Installer
545
553
  end
546
554
  end
547
555
 
548
- # DOC: Missing docs or :nodoc:.
549
- def ensure_required_rubygems_version_met
556
+ def ensure_required_rubygems_version_met # :nodoc:
550
557
  if rrgv = spec.required_rubygems_version then
551
558
  unless rrgv.satisfied_by? Gem.rubygems_version then
552
559
  raise Gem::InstallError,
@@ -556,8 +563,7 @@ class Gem::Installer
556
563
  end
557
564
  end
558
565
 
559
- # DOC: Missing docs or :nodoc:.
560
- def ensure_dependencies_met
566
+ def ensure_dependencies_met # :nodoc:
561
567
  deps = spec.runtime_dependencies
562
568
  deps |= spec.development_dependencies if @development
563
569
 
@@ -566,8 +572,7 @@ class Gem::Installer
566
572
  end
567
573
  end
568
574
 
569
- # DOC: Missing docs or :nodoc:.
570
- def process_options
575
+ def process_options # :nodoc:
571
576
  @options = {
572
577
  :bin_dir => nil,
573
578
  :env_shebang => false,
@@ -590,12 +595,20 @@ class Gem::Installer
590
595
  # (or use) a new bin dir under the gem_home.
591
596
  @bin_dir = options[:bin_dir] || Gem.bindir(gem_home)
592
597
  @development = options[:development]
598
+ @build_root = options[:build_root]
593
599
 
594
600
  @build_args = options[:build_args] || Gem::Command.build_args
601
+
602
+ unless @build_root.nil?
603
+ require 'pathname'
604
+ @build_root = Pathname.new(@build_root).expand_path
605
+ @bin_dir = File.join(@build_root, options[:bin_dir] || Gem.bindir(@gem_home))
606
+ @gem_home = File.join(@build_root, @gem_home)
607
+ alert_warning "You build with buildroot.\n Build root: #{@build_root}\n Bin dir: #{@bin_dir}\n Gem home: #{@gem_home}"
608
+ end
595
609
  end
596
610
 
597
- # DOC: Missing docs or :nodoc:.
598
- def check_that_user_bin_dir_is_in_path
611
+ def check_that_user_bin_dir_is_in_path # :nodoc:
599
612
  user_bin_dir = @bin_dir || Gem.bindir(gem_home)
600
613
  user_bin_dir = user_bin_dir.gsub(File::SEPARATOR, File::ALT_SEPARATOR) if
601
614
  File::ALT_SEPARATOR
@@ -606,16 +619,19 @@ class Gem::Installer
606
619
  user_bin_dir = user_bin_dir.downcase
607
620
  end
608
621
 
609
- unless path.split(File::PATH_SEPARATOR).include? user_bin_dir then
610
- unless self.class.path_warning then
611
- alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run."
612
- self.class.path_warning = true
622
+ path = path.split(File::PATH_SEPARATOR)
623
+
624
+ unless path.include? user_bin_dir then
625
+ unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV['HOME'], '~'))
626
+ unless self.class.path_warning then
627
+ alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run."
628
+ self.class.path_warning = true
629
+ end
613
630
  end
614
631
  end
615
632
  end
616
633
 
617
- # DOC: Missing docs or :nodoc:.
618
- def verify_gem_home(unpack = false)
634
+ def verify_gem_home(unpack = false) # :nodoc:
619
635
  FileUtils.mkdir_p gem_home
620
636
  raise Gem::FilePermissionError, gem_home unless
621
637
  unpack or File.writable?(gem_home)
@@ -101,6 +101,8 @@ class Gem::InstallerTestCase < Gem::TestCase
101
101
 
102
102
  @installer = util_installer @spec, @gemhome
103
103
  @user_installer = util_installer @user_spec, Gem.user_dir, :user
104
+
105
+ Gem::Installer.path_warning = false
104
106
  end
105
107
 
106
108
  def util_gem_bindir spec = @spec # :nodoc: