rubygems-update 3.1.5 → 3.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78a4d800b2d75e1b49ee618dee0f663d8b9cecb90fe46043b65a88865aa4fc78
4
- data.tar.gz: a4535a4ee7fd3e14a60c11d1ec8c82c01063c7023f4b5a63070e8dfbc322b3c9
3
+ metadata.gz: cf1897c1f4290a7c09ac7fc031441915d225aaa7ffab473229a244310eaa39ac
4
+ data.tar.gz: d6aef4fc02c767b99957e4dfaff7818399b9fb59de550d23bee19256b618a5f6
5
5
  SHA512:
6
- metadata.gz: 1c0b699ea3e0a12b393e4f54fb2bb095ff26bcb52911d77ae38dbe82d6591e061d6a9e6b99bb475aed7c2ed48a83e81ad36e4eebda065a86aaf3385d553bbeb8
7
- data.tar.gz: 3710d47156752e7ef3d4cdf8e1aab2a6e0aaf8e80cc9f79a9314f5774a1ea64d7a40283989e5f8fc6d67e2fb4616531d391d892536155a1f78bb6fab1657c924
6
+ metadata.gz: 2421931e30162b92a93891c80eb17bd3d78a135da9019f49a18ce701bf4ca1fa7731260f4cc6de1342a74accceb8df21024ccd5042cbefa9a89cf67c69528a54
7
+ data.tar.gz: 131eb583b3864dec611fab7574a8ebf75cc796288ed2a4c43e96d6b53d24509f282e83fa36b2851ad5e5c21b6d8f78fc3fadc3da974575428b3489d3d28d3a88
@@ -1,5 +1,15 @@
1
1
  # coding: UTF-8
2
2
 
3
+ === 3.1.6 / 2021-01-26
4
+
5
+ Minor enhancements:
6
+
7
+ * Improve require. Pull request #3133 by David Rodríguez.
8
+ * Simplify nested gem activation exceptions. Pull request #3450 by David
9
+ Rodríguez.
10
+ * Fix correctness and performance regression in `require`. Pull request
11
+ #3639 by David Rodríguez.
12
+
3
13
  === 3.1.5 / 2020-12-09
4
14
 
5
15
  Minor enhancements:
@@ -4,7 +4,7 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2020-12-09".freeze
7
+ @built_at = "2021-01-26".freeze
8
8
  @git_commit_sha = "32a4159325".freeze
9
9
  @release = false
10
10
  # end ivars
@@ -9,7 +9,7 @@
9
9
  require 'rbconfig'
10
10
 
11
11
  module Gem
12
- VERSION = "3.1.5".freeze
12
+ VERSION = "3.1.6".freeze
13
13
  end
14
14
 
15
15
  # Must be first since it unloads the prelude from 1.9.2
@@ -659,22 +659,25 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
659
659
 
660
660
  index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
661
661
 
662
- index
662
+ index || 0
663
+ end
664
+
665
+ ##
666
+ # The number of paths in the `$LOAD_PATH` from activated gems. Used to
667
+ # prioritize `-I` and `ENV['RUBYLIB`]` entries during `require`.
668
+
669
+ def self.activated_gem_paths
670
+ @activated_gem_paths ||= 0
663
671
  end
664
672
 
665
673
  ##
666
674
  # Add a list of paths to the $LOAD_PATH at the proper place.
667
675
 
668
676
  def self.add_to_load_path(*paths)
669
- insert_index = load_path_insert_index
677
+ @activated_gem_paths = activated_gem_paths + paths.size
670
678
 
671
- if insert_index
672
- # gem directories must come after -I and ENV['RUBYLIB']
673
- $LOAD_PATH.insert(insert_index, *paths)
674
- else
675
- # we are probably testing in core, -I and RUBYLIB don't apply
676
- $LOAD_PATH.unshift(*paths)
677
- end
679
+ # gem directories must come after -I and ENV['RUBYLIB']
680
+ $LOAD_PATH.insert(Gem.load_path_insert_index, *paths)
678
681
  end
679
682
 
680
683
  @yaml_loaded = false
@@ -39,49 +39,40 @@ module Kernel
39
39
 
40
40
  path = path.to_path if path.respond_to? :to_path
41
41
 
42
- # Ensure -I beats a default gem
43
- # https://github.com/rubygems/rubygems/pull/1868
44
- resolved_path = begin
45
- rp = nil
46
- $LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
47
- safe_lp = lp.dup.tap(&Gem::UNTAINT)
48
- begin
49
- if File.symlink? safe_lp # for backward compatibility
50
- next
51
- end
52
- rescue SecurityError
53
- RUBYGEMS_ACTIVATION_MONITOR.exit
54
- raise
55
- end
56
-
42
+ if spec = Gem.find_unresolved_default_spec(path)
43
+ # Ensure -I beats a default gem
44
+ resolved_path = begin
45
+ rp = nil
46
+ load_path_check_index = Gem.load_path_insert_index - Gem.activated_gem_paths
57
47
  Gem.suffixes.each do |s|
58
- full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
59
- if File.file?(full_path)
60
- rp = full_path
61
- break
48
+ $LOAD_PATH[0...load_path_check_index].each do |lp|
49
+ safe_lp = lp.dup.tap(&Gem::UNTAINT)
50
+ begin
51
+ if File.symlink? safe_lp # for backward compatibility
52
+ next
53
+ end
54
+ rescue SecurityError
55
+ RUBYGEMS_ACTIVATION_MONITOR.exit
56
+ raise
57
+ end
58
+
59
+ full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
60
+ if File.file?(full_path)
61
+ rp = full_path
62
+ break
63
+ end
62
64
  end
65
+ break if rp
63
66
  end
64
- break if rp
65
- end
66
- rp
67
- end
68
-
69
- if resolved_path
70
- begin
71
- RUBYGEMS_ACTIVATION_MONITOR.exit
72
- return gem_original_require(resolved_path)
73
- rescue LoadError
74
- RUBYGEMS_ACTIVATION_MONITOR.enter
67
+ rp
75
68
  end
76
- end
77
69
 
78
- if spec = Gem.find_unresolved_default_spec(path)
79
70
  begin
80
71
  Kernel.send(:gem, spec.name, Gem::Requirement.default_prerelease)
81
72
  rescue Exception
82
73
  RUBYGEMS_ACTIVATION_MONITOR.exit
83
74
  raise
84
- end
75
+ end unless resolved_path
85
76
  end
86
77
 
87
78
  # If there are no unresolved deps, then we can use just try
@@ -157,8 +148,7 @@ module Kernel
157
148
  RUBYGEMS_ACTIVATION_MONITOR.enter
158
149
 
159
150
  begin
160
- if load_error.message.start_with?("Could not find") or
161
- (load_error.message.end_with?(path) and Gem.try_activate(path))
151
+ if load_error.message.end_with?(path) and Gem.try_activate(path)
162
152
  require_again = true
163
153
  end
164
154
  ensure
@@ -385,6 +385,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
385
385
  Gem::Security.reset
386
386
 
387
387
  Gem.loaded_specs.clear
388
+ Gem.instance_variable_set(:@activated_gem_paths, 0)
388
389
  Gem.clear_default_specs
389
390
  Bundler.reset!
390
391
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rubygems-update"
5
- s.version = "3.1.5"
5
+ s.version = "3.1.6"
6
6
  s.authors = ["Jim Weirich", "Chad Fowler", "Eric Hodel", "Luis Lavena", "Aaron Patterson", "Samuel Giddins", "André Arko", "Evan Phoenix", "Hiroshi SHIBATA"]
7
7
  s.email = ["", "", "drbrain@segment7.net", "luislavena@gmail.com", "aaron@tenderlovemaking.com", "segiddins@segiddins.me", "andre@arko.net", "evan@phx.io", "hsbt@ruby-lang.org"]
8
8
 
@@ -62,5 +62,6 @@ if ENV["CI"] || ENV["TEST_SSL"]
62
62
  def test_accessing_new_index
63
63
  assert_https('index.rubygems.org')
64
64
  end
65
+
65
66
  end
66
67
  end
@@ -91,6 +91,25 @@ class TestKernel < Gem::TestCase
91
91
  refute $:.any? { |p| %r{a-1/bin} =~ p }
92
92
  end
93
93
 
94
+ def test_gem_failing_inside_require_doesnt_cause_double_exceptions
95
+ File.write("activate.rb", "gem('a', '= 999')\n")
96
+
97
+ require "open3"
98
+
99
+ output, _ = Open3.capture2e(
100
+ { "GEM_HOME" => Gem.paths.home },
101
+ Gem.ruby,
102
+ "-I",
103
+ File.expand_path("../../lib", __dir__),
104
+ "-r",
105
+ "./activate.rb"
106
+ )
107
+
108
+ load_errors = output.split("\n").select { |line| line.include?("Could not find")}
109
+
110
+ assert_equal 1, load_errors.size
111
+ end
112
+
94
113
  def test_gem_bundler
95
114
  quick_gem 'bundler', '1'
96
115
  quick_gem 'bundler', '2.a'
@@ -45,6 +45,35 @@ class TestGemRequire < Gem::TestCase
45
45
  refute require(path), "'#{path}' was not yet required"
46
46
  end
47
47
 
48
+ def test_respect_loaded_features_caching_like_standard_require
49
+ dir = Dir.mktmpdir("test_require", @tempdir)
50
+
51
+ lp1 = File.join dir, 'foo1'
52
+ foo1 = File.join lp1, 'foo.rb'
53
+
54
+ FileUtils.mkdir_p lp1
55
+ File.open(foo1, 'w') { |f| f.write "class Object; HELLO = 'foo1' end" }
56
+
57
+ lp = $LOAD_PATH.dup
58
+
59
+ $LOAD_PATH.unshift lp1
60
+ assert_require 'foo'
61
+ assert_equal "foo1", ::Object::HELLO
62
+
63
+ lp2 = File.join dir, 'foo2'
64
+ foo2 = File.join lp2, 'foo.rb'
65
+
66
+ FileUtils.mkdir_p lp2
67
+ File.open(foo2, 'w') { |f| f.write "class Object; HELLO = 'foo2' end" }
68
+
69
+ $LOAD_PATH.unshift lp2
70
+ refute_require 'foo'
71
+ assert_equal "foo1", ::Object::HELLO
72
+ ensure
73
+ $LOAD_PATH.replace lp
74
+ Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
75
+ end
76
+
48
77
  # Providing -I on the commandline should always beat gems
49
78
  def test_dash_i_beats_gems
50
79
  a1 = util_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
@@ -120,6 +149,24 @@ class TestGemRequire < Gem::TestCase
120
149
  Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
121
150
  end
122
151
 
152
+ def test_dash_i_respects_default_library_extension_priority
153
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
154
+
155
+ dash_i_ext_arg = util_install_extension_file('a')
156
+ dash_i_lib_arg = util_install_ruby_file('a')
157
+
158
+ lp = $LOAD_PATH.dup
159
+
160
+ begin
161
+ $LOAD_PATH.unshift dash_i_lib_arg
162
+ $LOAD_PATH.unshift dash_i_ext_arg
163
+ assert_require 'a'
164
+ assert_match(/a\.rb$/, $LOADED_FEATURES.last)
165
+ ensure
166
+ $LOAD_PATH.replace lp
167
+ end
168
+ end
169
+
123
170
  def test_concurrent_require
124
171
  Object.const_set :FILE_ENTERED_LATCH, Latch.new(2)
125
172
  Object.const_set :FILE_EXIT_LATCH, Latch.new(1)
@@ -364,6 +411,17 @@ class TestGemRequire < Gem::TestCase
364
411
  assert_equal 0, times_called
365
412
  end
366
413
 
414
+ def test_second_gem_require_does_not_resolve_path_manually_before_going_through_standard_require
415
+ a1 = util_spec "a", "1", nil, "lib/test_gem_require_a.rb"
416
+ install_gem a1
417
+
418
+ assert_require "test_gem_require_a"
419
+
420
+ stub(:gem_original_require, ->(path) { assert_equal "test_gem_require_a", path }) do
421
+ require "test_gem_require_a"
422
+ end
423
+ end
424
+
367
425
  def test_realworld_default_gem
368
426
  testing_ruby_repo = !ENV["GEM_COMMAND"].nil?
369
427
  skip "this test can't work under ruby-core setup" if testing_ruby_repo || java_platform?
@@ -539,4 +597,50 @@ class TestGemRequire < Gem::TestCase
539
597
  $VERBOSE = old_verbose
540
598
  end
541
599
 
600
+ def util_install_extension_file(name)
601
+ spec = quick_gem name
602
+ util_build_gem spec
603
+
604
+ spec.extensions << "extconf.rb"
605
+ write_file File.join(@tempdir, "extconf.rb") do |io|
606
+ io.write <<-RUBY
607
+ require "mkmf"
608
+ CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
609
+ create_makefile("#{name}")
610
+ RUBY
611
+ end
612
+
613
+ write_file File.join(@tempdir, "#{name}.c") do |io|
614
+ io.write <<-C
615
+ void Init_#{name}() { }
616
+ C
617
+ end
618
+
619
+ write_file File.join(@tempdir, "depend")
620
+
621
+ spec.files += ["extconf.rb", "depend", "#{name}.c"]
622
+
623
+ so = File.join(spec.gem_dir, "#{name}.#{RbConfig::CONFIG["DLEXT"]}")
624
+ refute_path_exists so
625
+
626
+ path = Gem::Package.build spec
627
+ installer = Gem::Installer.at path
628
+ installer.install
629
+ assert_path_exists so
630
+
631
+ spec.gem_dir
632
+ end
633
+
634
+ def util_install_ruby_file(name)
635
+ dir_lib = Dir.mktmpdir("test_require_lib", @tempdir)
636
+ dash_i_lib_arg = File.join dir_lib
637
+
638
+ a_rb = File.join dash_i_lib_arg, "#{name}.rb"
639
+
640
+ FileUtils.mkdir_p File.dirname a_rb
641
+ File.open(a_rb, 'w') { |f| f.write "# #{name}.rb" }
642
+
643
+ dash_i_lib_arg
644
+ end
645
+
542
646
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-update
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.5
4
+ version: 3.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2020-12-09 00:00:00.000000000 Z
19
+ date: 2021-01-26 00:00:00.000000000 Z
20
20
  dependencies: []
21
21
  description: |-
22
22
  A package (also known as a library) contains a set of functionality
@@ -819,8 +819,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
819
819
  - !ruby/object:Gem::Version
820
820
  version: '0'
821
821
  requirements: []
822
- rubyforge_project:
823
- rubygems_version: 2.7.6.2
822
+ rubygems_version: 3.0.3.1
824
823
  signing_key:
825
824
  specification_version: 4
826
825
  summary: RubyGems is a package management framework for Ruby.