bootsnap 1.9.1 → 1.9.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/bootsnap/load_path_cache/cache.rb +21 -7
- data/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb +3 -19
- data/lib/bootsnap/load_path_cache/loaded_features_index.rb +10 -2
- data/lib/bootsnap/version.rb +1 -1
- data/lib/bootsnap.rb +29 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de52d100052f98bd60ccbc71d3172b7f7951df2fb45fb8dab4a5c4f8e95e4528
|
4
|
+
data.tar.gz: a09dacba13131d47509d41d729748a7d80703779bcbbb0a4c0474f0960cf5025
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31fe33d4e05c9c85f4950434481131396dcc06485651144783767485da5ff887a6293aeb21d6baee22d3beeeb4c8e0a1ddb869f6f50b148bb241c674ee2b9f6a
|
7
|
+
data.tar.gz: 3e9a66ee5d26a54fa9c36515806c89f0757232b3191768f9769333155f08b5eda43d426c23a7ac144bd84ebd6d352042562bce8c828cbb2e8d624484d5adeb72
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# 1.9.2
|
4
|
+
|
5
|
+
* Disable compile cache if Ruby 3.0.3's ISeq cache bug is detected.
|
6
|
+
* Fix `Kernel.load` behavior: before `load 'a'` would load `a.rb` (and other tried extensions) and wouldn't load `a` unless `development_mode: true`, now only `a` would be loaded and files with extensions wouldn't be.
|
7
|
+
|
3
8
|
# 1.9.1
|
4
9
|
|
5
10
|
* Removed a forgotten debug statement in JSON precompilation.
|
@@ -44,14 +44,20 @@ module Bootsnap
|
|
44
44
|
|
45
45
|
# Try to resolve this feature to an absolute path without traversing the
|
46
46
|
# loadpath.
|
47
|
-
def find(feature)
|
47
|
+
def find(feature, try_extensions: true)
|
48
48
|
reinitialize if (@has_relative_paths && dir_changed?) || stale?
|
49
49
|
feature = feature.to_s.freeze
|
50
|
+
|
50
51
|
return feature if absolute_path?(feature)
|
51
|
-
|
52
|
+
|
53
|
+
if feature.start_with?('./', '../')
|
54
|
+
return try_extensions ? expand_path(feature) : File.expand_path(feature).freeze
|
55
|
+
end
|
56
|
+
|
52
57
|
@mutex.synchronize do
|
53
|
-
x = search_index(feature)
|
58
|
+
x = search_index(feature, try_extensions: try_extensions)
|
54
59
|
return x if x
|
60
|
+
return unless try_extensions
|
55
61
|
|
56
62
|
# Ruby has some built-in features that require lies about.
|
57
63
|
# For example, 'enumerator' is built in. If you require it, ruby
|
@@ -177,16 +183,24 @@ module Bootsnap
|
|
177
183
|
end
|
178
184
|
|
179
185
|
if DLEXT2
|
180
|
-
def search_index(f)
|
181
|
-
|
186
|
+
def search_index(f, try_extensions: true)
|
187
|
+
if try_extensions
|
188
|
+
try_index(f + DOT_RB) || try_index(f + DLEXT) || try_index(f + DLEXT2) || try_index(f)
|
189
|
+
else
|
190
|
+
try_index(f)
|
191
|
+
end
|
182
192
|
end
|
183
193
|
|
184
194
|
def maybe_append_extension(f)
|
185
195
|
try_ext(f + DOT_RB) || try_ext(f + DLEXT) || try_ext(f + DLEXT2) || f
|
186
196
|
end
|
187
197
|
else
|
188
|
-
def search_index(f)
|
189
|
-
|
198
|
+
def search_index(f, try_extensions: true)
|
199
|
+
if try_extensions
|
200
|
+
try_index(f + DOT_RB) || try_index(f + DLEXT) || try_index(f)
|
201
|
+
else
|
202
|
+
try_index(f)
|
203
|
+
end
|
190
204
|
end
|
191
205
|
|
192
206
|
def maybe_append_extension(f)
|
@@ -56,25 +56,9 @@ module Kernel
|
|
56
56
|
|
57
57
|
alias_method(:load_without_bootsnap, :load)
|
58
58
|
def load(path, wrap = false)
|
59
|
-
if (resolved = Bootsnap::LoadPathCache.load_path_cache.find(path))
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
# load also allows relative paths from pwd even when not in $:
|
64
|
-
if File.exist?(relative = File.expand_path(path).freeze)
|
65
|
-
return load_without_bootsnap(relative, wrap)
|
66
|
-
end
|
67
|
-
|
68
|
-
raise(Bootsnap::LoadPathCache::CoreExt.make_load_error(path))
|
69
|
-
rescue LoadError => e
|
70
|
-
e.instance_variable_set(Bootsnap::LoadPathCache::ERROR_TAG_IVAR, true)
|
71
|
-
raise(e)
|
72
|
-
rescue Bootsnap::LoadPathCache::ReturnFalse
|
73
|
-
false
|
74
|
-
rescue Bootsnap::LoadPathCache::FallbackScan
|
75
|
-
fallback = true
|
76
|
-
ensure
|
77
|
-
if fallback
|
59
|
+
if (resolved = Bootsnap::LoadPathCache.load_path_cache.find(path, try_extensions: false))
|
60
|
+
load_without_bootsnap(resolved, wrap)
|
61
|
+
else
|
78
62
|
load_without_bootsnap(path, wrap)
|
79
63
|
end
|
80
64
|
end
|
@@ -84,10 +84,18 @@ module Bootsnap
|
|
84
84
|
# entry.
|
85
85
|
def register(short, long = nil)
|
86
86
|
if long.nil?
|
87
|
-
pat = %r{/#{Regexp.escape(short)}(\.[^/]+)?$}
|
88
87
|
len = $LOADED_FEATURES.size
|
89
88
|
ret = yield
|
90
|
-
long = $LOADED_FEATURES[len..-1].detect
|
89
|
+
long = $LOADED_FEATURES[len..-1].detect do |feat|
|
90
|
+
offset = 0
|
91
|
+
while offset = feat.index(short, offset)
|
92
|
+
if feat.index(".", offset + 1) && !feat.index("/", offset + 2)
|
93
|
+
break true
|
94
|
+
else
|
95
|
+
offset += 1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
91
99
|
else
|
92
100
|
ret = yield
|
93
101
|
end
|
data/lib/bootsnap/version.rb
CHANGED
data/lib/bootsnap.rb
CHANGED
@@ -57,9 +57,15 @@ module Bootsnap
|
|
57
57
|
"If you use Ruby 2.5 or newer this option is useless, if not upgrading is recommended."
|
58
58
|
end
|
59
59
|
|
60
|
-
if compile_cache_iseq
|
61
|
-
|
62
|
-
"
|
60
|
+
if compile_cache_iseq
|
61
|
+
if iseq_cache_tracing_bug?
|
62
|
+
warn "Ruby 2.5 has a bug that break code tracing when code is loaded from cache. It is recommended " \
|
63
|
+
"to turn `compile_cache_iseq` off on Ruby 2.5"
|
64
|
+
end
|
65
|
+
|
66
|
+
if iseq_cache_anonymous_params_bug?
|
67
|
+
warn "Your version of Ruby 3.1.0-dev has a bug that break bytecode caching (https://github.com/ruby/ruby/pull/4961)."
|
68
|
+
end
|
63
69
|
end
|
64
70
|
|
65
71
|
Bootsnap::LoadPathCache.setup(
|
@@ -75,11 +81,28 @@ module Bootsnap
|
|
75
81
|
)
|
76
82
|
end
|
77
83
|
|
78
|
-
def self.
|
79
|
-
return @
|
84
|
+
def self.iseq_cache_tracing_bug?
|
85
|
+
return @iseq_cache_tracing_bug if defined? @iseq_cache_tracing_bug
|
80
86
|
|
81
87
|
ruby_version = Gem::Version.new(RUBY_VERSION)
|
82
|
-
@
|
88
|
+
@iseq_cache_tracing_bug = ruby_version < Gem::Version.new('2.5.0') || ruby_version >= Gem::Version.new('2.6.0')
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.iseq_cache_anonymous_params_bug?
|
92
|
+
return @iseq_cache_anonymous_params_bug if defined? @iseq_cache_anonymous_params_bug
|
93
|
+
begin
|
94
|
+
if defined? RubyVM::InstructionSequence
|
95
|
+
RubyVM::InstructionSequence.compile("def foo(*); ->{ super }; end").to_binary
|
96
|
+
RubyVM::InstructionSequence.compile("def foo(**); ->{ super }; end").to_binary
|
97
|
+
end
|
98
|
+
false
|
99
|
+
rescue TypeError
|
100
|
+
true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.iseq_cache_supported?
|
105
|
+
!(iseq_cache_tracing_bug? || iseq_cache_anonymous_params_bug?)
|
83
106
|
end
|
84
107
|
|
85
108
|
def self.default_setup
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootsnap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|