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 +4 -4
- data/History.txt +10 -0
- data/bundler/lib/bundler/build_metadata.rb +1 -1
- data/lib/rubygems.rb +13 -10
- data/lib/rubygems/core_ext/kernel_require.rb +25 -35
- data/lib/rubygems/test_case.rb +1 -0
- data/rubygems-update.gemspec +1 -1
- data/test/rubygems/test_bundled_ca.rb +1 -0
- data/test/rubygems/test_kernel.rb +19 -0
- data/test/rubygems/test_require.rb +104 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf1897c1f4290a7c09ac7fc031441915d225aaa7ffab473229a244310eaa39ac
|
4
|
+
data.tar.gz: d6aef4fc02c767b99957e4dfaff7818399b9fb59de550d23bee19256b618a5f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2421931e30162b92a93891c80eb17bd3d78a135da9019f49a18ce701bf4ca1fa7731260f4cc6de1342a74accceb8df21024ccd5042cbefa9a89cf67c69528a54
|
7
|
+
data.tar.gz: 131eb583b3864dec611fab7574a8ebf75cc796288ed2a4c43e96d6b53d24509f282e83fa36b2851ad5e5c21b6d8f78fc3fadc3da974575428b3489d3d28d3a88
|
data/History.txt
CHANGED
@@ -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:
|
data/lib/rubygems.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
require 'rbconfig'
|
10
10
|
|
11
11
|
module Gem
|
12
|
-
VERSION = "3.1.
|
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
|
-
|
677
|
+
@activated_gem_paths = activated_gem_paths + paths.size
|
670
678
|
|
671
|
-
|
672
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
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.
|
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
|
data/lib/rubygems/test_case.rb
CHANGED
data/rubygems-update.gemspec
CHANGED
@@ -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
|
+
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
|
|
@@ -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.
|
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:
|
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
|
-
|
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.
|