bootsnap 1.9.4 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/exe/bootsnap +1 -1
- data/ext/bootsnap/bootsnap.c +38 -36
- data/ext/bootsnap/extconf.rb +13 -11
- data/lib/bootsnap/bundler.rb +1 -0
- data/lib/bootsnap/cli/worker_pool.rb +1 -0
- data/lib/bootsnap/cli.rb +49 -49
- data/lib/bootsnap/compile_cache/iseq.rb +16 -11
- data/lib/bootsnap/compile_cache/json.rb +15 -8
- data/lib/bootsnap/compile_cache/yaml.rb +216 -78
- data/lib/bootsnap/compile_cache.rb +10 -7
- data/lib/bootsnap/explicit_require.rb +4 -3
- data/lib/bootsnap/load_path_cache/cache.rb +42 -30
- data/lib/bootsnap/load_path_cache/change_observer.rb +2 -0
- data/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb +29 -18
- data/lib/bootsnap/load_path_cache/core_ext/loaded_features.rb +1 -0
- data/lib/bootsnap/load_path_cache/loaded_features_index.rb +31 -33
- data/lib/bootsnap/load_path_cache/path.rb +5 -3
- data/lib/bootsnap/load_path_cache/path_scanner.rb +6 -5
- data/lib/bootsnap/load_path_cache/realpath_cache.rb +1 -0
- data/lib/bootsnap/load_path_cache/store.rb +12 -7
- data/lib/bootsnap/load_path_cache.rb +15 -15
- data/lib/bootsnap/setup.rb +2 -1
- data/lib/bootsnap/version.rb +2 -1
- data/lib/bootsnap.rb +32 -31
- metadata +5 -75
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Bootsnap
|
3
4
|
module LoadPathCache
|
4
5
|
module ChangeObserver
|
@@ -57,6 +58,7 @@ module Bootsnap
|
|
57
58
|
|
58
59
|
def self.register(observer, arr)
|
59
60
|
return if arr.frozen? # can't register observer, but no need to.
|
61
|
+
|
60
62
|
arr.instance_variable_set(:@lpc_observer, observer)
|
61
63
|
arr.extend(ArrayMixin)
|
62
64
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Bootsnap
|
3
4
|
module LoadPathCache
|
4
5
|
module CoreExt
|
@@ -13,35 +14,42 @@ module Bootsnap
|
|
13
14
|
end
|
14
15
|
|
15
16
|
module Kernel
|
16
|
-
module_function
|
17
|
+
module_function
|
17
18
|
|
18
19
|
alias_method(:require_without_bootsnap, :require)
|
19
20
|
|
20
|
-
# Note that require registers to $LOADED_FEATURES while load does not.
|
21
|
-
def require_with_bootsnap_lfi(path, resolved = nil)
|
22
|
-
Bootsnap::LoadPathCache.loaded_features_index.register(path, resolved) do
|
23
|
-
require_without_bootsnap(resolved || path)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
21
|
def require(path)
|
28
|
-
|
22
|
+
fallback = false
|
23
|
+
string_path = path.to_s
|
24
|
+
return false if Bootsnap::LoadPathCache.loaded_features_index.key?(string_path)
|
29
25
|
|
30
|
-
if (resolved = Bootsnap::LoadPathCache.load_path_cache.find(
|
31
|
-
|
26
|
+
if (resolved = Bootsnap::LoadPathCache.load_path_cache.find(string_path))
|
27
|
+
# Note that require registers to $LOADED_FEATURES while load does not.
|
28
|
+
ret = require_without_bootsnap(resolved)
|
29
|
+
Bootsnap::LoadPathCache.loaded_features_index.register(string_path, resolved)
|
30
|
+
return ret
|
32
31
|
end
|
33
32
|
|
34
33
|
raise(Bootsnap::LoadPathCache::CoreExt.make_load_error(path))
|
35
|
-
rescue LoadError =>
|
36
|
-
|
37
|
-
raise(
|
34
|
+
rescue LoadError => error
|
35
|
+
error.instance_variable_set(Bootsnap::LoadPathCache::ERROR_TAG_IVAR, true)
|
36
|
+
raise(error)
|
38
37
|
rescue Bootsnap::LoadPathCache::ReturnFalse
|
39
38
|
false
|
40
39
|
rescue Bootsnap::LoadPathCache::FallbackScan
|
41
40
|
fallback = true
|
42
41
|
ensure
|
42
|
+
# We raise from `ensure` so that any further exception don't have FallbackScan as a cause
|
43
|
+
# See: https://github.com/Shopify/bootsnap/issues/250
|
43
44
|
if fallback
|
44
|
-
|
45
|
+
if (cursor = Bootsnap::LoadPathCache.loaded_features_index.cursor(string_path))
|
46
|
+
ret = require_without_bootsnap(path)
|
47
|
+
resolved = Bootsnap::LoadPathCache.loaded_features_index.identify(string_path, cursor)
|
48
|
+
Bootsnap::LoadPathCache.loaded_features_index.register(string_path, resolved)
|
49
|
+
ret
|
50
|
+
else # If we're not given a cursor, it means we don't need to register the path (likely an absolute path)
|
51
|
+
require_without_bootsnap(path)
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
47
55
|
|
@@ -67,6 +75,7 @@ end
|
|
67
75
|
class Module
|
68
76
|
alias_method(:autoload_without_bootsnap, :autoload)
|
69
77
|
def autoload(const, path)
|
78
|
+
fallback = false
|
70
79
|
# NOTE: This may defeat LoadedFeaturesIndex, but it's not immediately
|
71
80
|
# obvious how to make it work. This feels like a pretty niche case, unclear
|
72
81
|
# if it will ever burn anyone.
|
@@ -75,14 +84,16 @@ class Module
|
|
75
84
|
# added to $LOADED_FEATURES and won't be able to hook that modification
|
76
85
|
# since it's done in C-land.
|
77
86
|
autoload_without_bootsnap(const, Bootsnap::LoadPathCache.load_path_cache.find(path) || path)
|
78
|
-
rescue LoadError =>
|
79
|
-
|
80
|
-
raise(
|
87
|
+
rescue LoadError => error
|
88
|
+
error.instance_variable_set(Bootsnap::LoadPathCache::ERROR_TAG_IVAR, true)
|
89
|
+
raise(error)
|
81
90
|
rescue Bootsnap::LoadPathCache::ReturnFalse
|
82
91
|
false
|
83
92
|
rescue Bootsnap::LoadPathCache::FallbackScan
|
84
93
|
fallback = true
|
85
94
|
ensure
|
95
|
+
# We raise from `ensure` so that any further exception don't have FallbackScan as a cause
|
96
|
+
# See: https://github.com/Shopify/bootsnap/issues/250
|
86
97
|
if fallback
|
87
98
|
autoload_without_bootsnap(const, path)
|
88
99
|
end
|
@@ -29,14 +29,15 @@ module Bootsnap
|
|
29
29
|
@mutex = Mutex.new
|
30
30
|
|
31
31
|
# In theory the user could mutate $LOADED_FEATURES and invalidate our
|
32
|
-
# cache. If this ever comes up in practice
|
33
|
-
# enterprising reader, feels inclined to solve this problem
|
32
|
+
# cache. If this ever comes up in practice - or if you, the
|
33
|
+
# enterprising reader, feels inclined to solve this problem - we could
|
34
34
|
# parallel the work done with ChangeObserver on $LOAD_PATH to mirror
|
35
35
|
# updates to our @lfi.
|
36
36
|
$LOADED_FEATURES.each do |feat|
|
37
37
|
hash = feat.hash
|
38
38
|
$LOAD_PATH.each do |lpe|
|
39
39
|
next unless feat.start_with?(lpe)
|
40
|
+
|
40
41
|
# /a/b/lib/my/foo.rb
|
41
42
|
# ^^^^^^^^^
|
42
43
|
short = feat[(lpe.length + 1)..-1]
|
@@ -68,6 +69,25 @@ module Bootsnap
|
|
68
69
|
@mutex.synchronize { @lfi.key?(feature) }
|
69
70
|
end
|
70
71
|
|
72
|
+
def cursor(short)
|
73
|
+
unless Bootsnap.absolute_path?(short.to_s)
|
74
|
+
$LOADED_FEATURES.size
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def identify(short, cursor)
|
79
|
+
$LOADED_FEATURES[cursor..-1].detect do |feat|
|
80
|
+
offset = 0
|
81
|
+
while (offset = feat.index(short, offset))
|
82
|
+
if feat.index(".", offset + 1) && !feat.index("/", offset + 2)
|
83
|
+
break true
|
84
|
+
else
|
85
|
+
offset += 1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
71
91
|
# There is a relatively uncommon case where we could miss adding an
|
72
92
|
# entry:
|
73
93
|
#
|
@@ -82,28 +102,8 @@ module Bootsnap
|
|
82
102
|
# not quite right; or
|
83
103
|
# 2. Inspect $LOADED_FEATURES upon return from yield to find the matching
|
84
104
|
# entry.
|
85
|
-
def register(short, long
|
86
|
-
|
87
|
-
if Bootsnap.absolute_path?(short.to_s)
|
88
|
-
return yield
|
89
|
-
end
|
90
|
-
|
91
|
-
if long.nil?
|
92
|
-
len = $LOADED_FEATURES.size
|
93
|
-
ret = yield
|
94
|
-
long = $LOADED_FEATURES[len..-1].detect do |feat|
|
95
|
-
offset = 0
|
96
|
-
while offset = feat.index(short, offset)
|
97
|
-
if feat.index(".", offset + 1) && !feat.index("/", offset + 2)
|
98
|
-
break true
|
99
|
-
else
|
100
|
-
offset += 1
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
else
|
105
|
-
ret = yield
|
106
|
-
end
|
105
|
+
def register(short, long)
|
106
|
+
return if Bootsnap.absolute_path?(short)
|
107
107
|
|
108
108
|
hash = long.hash
|
109
109
|
|
@@ -122,13 +122,11 @@ module Bootsnap
|
|
122
122
|
@lfi[short] = hash
|
123
123
|
(@lfi[altname] = hash) if altname
|
124
124
|
end
|
125
|
-
|
126
|
-
ret
|
127
125
|
end
|
128
126
|
|
129
127
|
private
|
130
128
|
|
131
|
-
STRIP_EXTENSION = /\.[^.]
|
129
|
+
STRIP_EXTENSION = /\.[^.]*?$/.freeze
|
132
130
|
private_constant(:STRIP_EXTENSION)
|
133
131
|
|
134
132
|
# Might Ruby automatically search for this extension if
|
@@ -145,15 +143,15 @@ module Bootsnap
|
|
145
143
|
# with calling a Ruby file 'x.dylib.rb' and then requiring it as 'x.dylib'.)
|
146
144
|
#
|
147
145
|
# See <https://ruby-doc.org/core-2.6.4/Kernel.html#method-i-require>.
|
148
|
-
def extension_elidable?(
|
149
|
-
|
146
|
+
def extension_elidable?(feature)
|
147
|
+
feature.to_s.end_with?(".rb", ".so", ".o", ".dll", ".dylib")
|
150
148
|
end
|
151
149
|
|
152
|
-
def strip_extension_if_elidable(
|
153
|
-
if extension_elidable?(
|
154
|
-
|
150
|
+
def strip_extension_if_elidable(feature)
|
151
|
+
if extension_elidable?(feature)
|
152
|
+
feature.sub(STRIP_EXTENSION, "")
|
155
153
|
else
|
156
|
-
|
154
|
+
feature
|
157
155
|
end
|
158
156
|
end
|
159
157
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require_relative("path_scanner")
|
3
4
|
|
4
5
|
module Bootsnap
|
5
6
|
module LoadPathCache
|
@@ -43,6 +44,7 @@ module Bootsnap
|
|
43
44
|
# set to zero anyway, just in case we change the stability heuristics.
|
44
45
|
_, entries, dirs = store.get(expanded_path)
|
45
46
|
return [entries, dirs] if entries # cache hit
|
47
|
+
|
46
48
|
entries, dirs = scan!
|
47
49
|
store.set(expanded_path, [0, entries, dirs])
|
48
50
|
return [entries, dirs]
|
@@ -93,8 +95,8 @@ module Bootsnap
|
|
93
95
|
|
94
96
|
# Built-in ruby lib stuff doesn't change, but things can occasionally be
|
95
97
|
# installed into sitedir, which generally lives under libdir.
|
96
|
-
RUBY_LIBDIR = RbConfig::CONFIG[
|
97
|
-
RUBY_SITEDIR = RbConfig::CONFIG[
|
98
|
+
RUBY_LIBDIR = RbConfig::CONFIG["libdir"]
|
99
|
+
RUBY_SITEDIR = RbConfig::CONFIG["sitedir"]
|
98
100
|
|
99
101
|
def stability
|
100
102
|
@stability ||= begin
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative(
|
3
|
+
require_relative("../explicit_require")
|
4
4
|
|
5
5
|
module Bootsnap
|
6
6
|
module LoadPathCache
|
7
7
|
module PathScanner
|
8
8
|
REQUIRABLE_EXTENSIONS = [DOT_RB] + DL_EXTENSIONS
|
9
9
|
NORMALIZE_NATIVE_EXTENSIONS = !DL_EXTENSIONS.include?(LoadPathCache::DOT_SO)
|
10
|
-
ALTERNATIVE_NATIVE_EXTENSIONS_PATTERN = /\.(o|bundle|dylib)\z
|
10
|
+
ALTERNATIVE_NATIVE_EXTENSIONS_PATTERN = /\.(o|bundle|dylib)\z/.freeze
|
11
11
|
|
12
12
|
BUNDLE_PATH = if Bootsnap.bundler?
|
13
13
|
(Bundler.bundle_path.cleanpath.to_s << LoadPathCache::SLASH).freeze
|
14
14
|
else
|
15
|
-
|
15
|
+
""
|
16
16
|
end
|
17
17
|
|
18
18
|
class << self
|
@@ -44,7 +44,8 @@ module Bootsnap
|
|
44
44
|
|
45
45
|
def walk(absolute_dir_path, relative_dir_path, &block)
|
46
46
|
Dir.foreach(absolute_dir_path) do |name|
|
47
|
-
next if name.start_with?(
|
47
|
+
next if name.start_with?(".")
|
48
|
+
|
48
49
|
relative_path = relative_dir_path ? File.join(relative_dir_path, name) : name
|
49
50
|
|
50
51
|
absolute_path = "#{absolute_dir_path}/#{name}"
|
@@ -58,7 +59,7 @@ module Bootsnap
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
|
-
if RUBY_VERSION >=
|
62
|
+
if RUBY_VERSION >= "3.1"
|
62
63
|
def os_path(path)
|
63
64
|
path.freeze
|
64
65
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require_relative('../explicit_require')
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
require_relative("../explicit_require")
|
4
|
+
|
5
|
+
Bootsnap::ExplicitRequire.with_gems("msgpack") { require("msgpack") }
|
6
6
|
|
7
7
|
module Bootsnap
|
8
8
|
module LoadPathCache
|
9
9
|
class Store
|
10
|
-
VERSION_KEY =
|
11
|
-
CURRENT_VERSION = "#{RUBY_REVISION}-#{RUBY_PLATFORM}".freeze
|
10
|
+
VERSION_KEY = "__bootsnap_ruby_version__"
|
11
|
+
CURRENT_VERSION = "#{RUBY_REVISION}-#{RUBY_PLATFORM}".freeze # rubocop:disable Style/RedundantFreeze
|
12
12
|
|
13
13
|
NestedTransactionError = Class.new(StandardError)
|
14
14
|
SetOutsideTransactionNotAllowed = Class.new(StandardError)
|
@@ -26,6 +26,7 @@ module Bootsnap
|
|
26
26
|
|
27
27
|
def fetch(key)
|
28
28
|
raise(SetOutsideTransactionNotAllowed) unless @txn_mutex.owned?
|
29
|
+
|
29
30
|
v = get(key)
|
30
31
|
unless v
|
31
32
|
@dirty = true
|
@@ -37,6 +38,7 @@ module Bootsnap
|
|
37
38
|
|
38
39
|
def set(key, value)
|
39
40
|
raise(SetOutsideTransactionNotAllowed) unless @txn_mutex.owned?
|
41
|
+
|
40
42
|
if value != @data[key]
|
41
43
|
@dirty = true
|
42
44
|
@data[key] = value
|
@@ -45,6 +47,7 @@ module Bootsnap
|
|
45
47
|
|
46
48
|
def transaction
|
47
49
|
raise(NestedTransactionError) if @txn_mutex.owned?
|
50
|
+
|
48
51
|
@txn_mutex.synchronize do
|
49
52
|
begin
|
50
53
|
yield
|
@@ -86,9 +89,11 @@ module Bootsnap
|
|
86
89
|
end
|
87
90
|
|
88
91
|
def dump_data
|
92
|
+
require "fileutils" unless defined? FileUtils
|
93
|
+
|
89
94
|
# Change contents atomically so other processes can't get invalid
|
90
95
|
# caches if they read at an inopportune time.
|
91
|
-
tmp = "#{@store_path}.#{Process.pid}.#{(rand *
|
96
|
+
tmp = "#{@store_path}.#{Process.pid}.#{(rand * 100_000).to_i}.tmp"
|
92
97
|
FileUtils.mkpath(File.dirname(tmp))
|
93
98
|
exclusive_write = File::Constants::CREAT | File::Constants::EXCL | File::Constants::WRONLY
|
94
99
|
# `encoding:` looks redundant wrt `binwrite`, but necessary on windows
|
@@ -103,7 +108,7 @@ module Bootsnap
|
|
103
108
|
end
|
104
109
|
|
105
110
|
def default_data
|
106
|
-
{
|
111
|
+
{VERSION_KEY => CURRENT_VERSION}
|
107
112
|
end
|
108
113
|
end
|
109
114
|
end
|
@@ -5,9 +5,9 @@ module Bootsnap
|
|
5
5
|
ReturnFalse = Class.new(StandardError)
|
6
6
|
FallbackScan = Class.new(StandardError)
|
7
7
|
|
8
|
-
DOT_RB =
|
9
|
-
DOT_SO =
|
10
|
-
SLASH =
|
8
|
+
DOT_RB = ".rb"
|
9
|
+
DOT_SO = ".so"
|
10
|
+
SLASH = "/"
|
11
11
|
|
12
12
|
# If a NameError happens several levels deep, don't re-handle it
|
13
13
|
# all the way up the chain: mark it once and bubble it up without
|
@@ -15,7 +15,7 @@ module Bootsnap
|
|
15
15
|
ERROR_TAG_IVAR = :@__bootsnap_rescued
|
16
16
|
|
17
17
|
DL_EXTENSIONS = ::RbConfig::CONFIG
|
18
|
-
.values_at(
|
18
|
+
.values_at("DLEXT", "DLEXT2")
|
19
19
|
.reject { |ext| !ext || ext.empty? }
|
20
20
|
.map { |ext| ".#{ext}" }
|
21
21
|
.freeze
|
@@ -42,24 +42,24 @@ module Bootsnap
|
|
42
42
|
@realpath_cache = RealpathCache.new
|
43
43
|
|
44
44
|
@load_path_cache = Cache.new(store, $LOAD_PATH, development_mode: development_mode)
|
45
|
-
require_relative(
|
46
|
-
require_relative(
|
45
|
+
require_relative("load_path_cache/core_ext/kernel_require")
|
46
|
+
require_relative("load_path_cache/core_ext/loaded_features")
|
47
47
|
end
|
48
48
|
|
49
49
|
def supported?
|
50
|
-
RUBY_ENGINE ==
|
51
|
-
|
50
|
+
RUBY_ENGINE == "ruby" &&
|
51
|
+
RUBY_PLATFORM =~ /darwin|linux|bsd|mswin|mingw|cygwin/
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
if Bootsnap::LoadPathCache.supported?
|
58
|
-
require_relative(
|
59
|
-
require_relative(
|
60
|
-
require_relative(
|
61
|
-
require_relative(
|
62
|
-
require_relative(
|
63
|
-
require_relative(
|
64
|
-
require_relative(
|
58
|
+
require_relative("load_path_cache/path_scanner")
|
59
|
+
require_relative("load_path_cache/path")
|
60
|
+
require_relative("load_path_cache/cache")
|
61
|
+
require_relative("load_path_cache/store")
|
62
|
+
require_relative("load_path_cache/change_observer")
|
63
|
+
require_relative("load_path_cache/loaded_features_index")
|
64
|
+
require_relative("load_path_cache/realpath_cache")
|
65
65
|
end
|
data/lib/bootsnap/setup.rb
CHANGED
data/lib/bootsnap/version.rb
CHANGED
data/lib/bootsnap.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative(
|
4
|
-
require_relative(
|
5
|
-
require_relative(
|
6
|
-
require_relative(
|
3
|
+
require_relative("bootsnap/version")
|
4
|
+
require_relative("bootsnap/bundler")
|
5
|
+
require_relative("bootsnap/load_path_cache")
|
6
|
+
require_relative("bootsnap/compile_cache")
|
7
7
|
|
8
8
|
module Bootsnap
|
9
9
|
InvalidConfiguration = Class.new(StandardError)
|
@@ -18,10 +18,10 @@ module Bootsnap
|
|
18
18
|
|
19
19
|
def self.logger=(logger)
|
20
20
|
@logger = logger
|
21
|
-
if logger.respond_to?(:debug)
|
22
|
-
|
21
|
+
self.instrumentation = if logger.respond_to?(:debug)
|
22
|
+
->(event, path) { @logger.debug("[Bootsnap] #{event} #{path}") }
|
23
23
|
else
|
24
|
-
|
24
|
+
->(event, path) { @logger.call("[Bootsnap] #{event} #{path}") }
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -62,13 +62,15 @@ module Bootsnap
|
|
62
62
|
"to turn `compile_cache_iseq` off on Ruby 2.5"
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
if load_path_cache
|
66
|
+
Bootsnap::LoadPathCache.setup(
|
67
|
+
cache_path: cache_dir + "/bootsnap/load-path-cache",
|
68
|
+
development_mode: development_mode,
|
69
|
+
)
|
70
|
+
end
|
69
71
|
|
70
72
|
Bootsnap::CompileCache.setup(
|
71
|
-
cache_dir: cache_dir +
|
73
|
+
cache_dir: cache_dir + "/bootsnap/compile-cache",
|
72
74
|
iseq: compile_cache_iseq,
|
73
75
|
yaml: compile_cache_yaml,
|
74
76
|
json: compile_cache_json,
|
@@ -79,18 +81,18 @@ module Bootsnap
|
|
79
81
|
return @iseq_cache_supported if defined? @iseq_cache_supported
|
80
82
|
|
81
83
|
ruby_version = Gem::Version.new(RUBY_VERSION)
|
82
|
-
@iseq_cache_supported = ruby_version < Gem::Version.new(
|
84
|
+
@iseq_cache_supported = ruby_version < Gem::Version.new("2.5.0") || ruby_version >= Gem::Version.new("2.6.0")
|
83
85
|
end
|
84
86
|
|
85
87
|
def self.default_setup
|
86
|
-
env = ENV[
|
87
|
-
development_mode = [
|
88
|
+
env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || ENV["ENV"]
|
89
|
+
development_mode = ["", nil, "development"].include?(env)
|
88
90
|
|
89
|
-
unless ENV[
|
90
|
-
cache_dir = ENV[
|
91
|
+
unless ENV["DISABLE_BOOTSNAP"]
|
92
|
+
cache_dir = ENV["BOOTSNAP_CACHE_DIR"]
|
91
93
|
unless cache_dir
|
92
94
|
config_dir_frame = caller.detect do |line|
|
93
|
-
line.include?(
|
95
|
+
line.include?("/config/")
|
94
96
|
end
|
95
97
|
|
96
98
|
unless config_dir_frame
|
@@ -102,35 +104,34 @@ module Bootsnap
|
|
102
104
|
end
|
103
105
|
|
104
106
|
path = config_dir_frame.split(/:\d+:/).first
|
105
|
-
path = File.dirname(path) until File.basename(path) ==
|
107
|
+
path = File.dirname(path) until File.basename(path) == "config"
|
106
108
|
app_root = File.dirname(path)
|
107
109
|
|
108
|
-
cache_dir = File.join(app_root,
|
110
|
+
cache_dir = File.join(app_root, "tmp", "cache")
|
109
111
|
end
|
110
112
|
|
111
|
-
|
112
113
|
setup(
|
113
|
-
cache_dir:
|
114
|
-
development_mode:
|
115
|
-
load_path_cache:
|
116
|
-
compile_cache_iseq:
|
117
|
-
compile_cache_yaml:
|
118
|
-
compile_cache_json:
|
114
|
+
cache_dir: cache_dir,
|
115
|
+
development_mode: development_mode,
|
116
|
+
load_path_cache: !ENV["DISABLE_BOOTSNAP_LOAD_PATH_CACHE"],
|
117
|
+
compile_cache_iseq: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"] && iseq_cache_supported?,
|
118
|
+
compile_cache_yaml: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"],
|
119
|
+
compile_cache_json: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"],
|
119
120
|
)
|
120
121
|
|
121
|
-
if ENV[
|
122
|
+
if ENV["BOOTSNAP_LOG"]
|
122
123
|
log!
|
123
124
|
end
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
127
|
-
if RbConfig::CONFIG[
|
128
|
+
if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
|
128
129
|
def self.absolute_path?(path)
|
129
|
-
path[1] ==
|
130
|
+
path[1] == ":"
|
130
131
|
end
|
131
132
|
else
|
132
133
|
def self.absolute_path?(path)
|
133
|
-
path.start_with?(
|
134
|
+
path.start_with?("/")
|
134
135
|
end
|
135
136
|
end
|
136
137
|
end
|
metadata
CHANGED
@@ -1,99 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootsnap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake-compiler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: mocha
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.2'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.2'
|
83
13
|
- !ruby/object:Gem::Dependency
|
84
14
|
name: msgpack
|
85
15
|
requirement: !ruby/object:Gem::Requirement
|
86
16
|
requirements:
|
87
17
|
- - "~>"
|
88
18
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
19
|
+
version: '1.2'
|
90
20
|
type: :runtime
|
91
21
|
prerelease: false
|
92
22
|
version_requirements: !ruby/object:Gem::Requirement
|
93
23
|
requirements:
|
94
24
|
- - "~>"
|
95
25
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
26
|
+
version: '1.2'
|
97
27
|
description: Boot large ruby/rails apps faster
|
98
28
|
email:
|
99
29
|
- burke.libbey@shopify.com
|
@@ -136,7 +66,7 @@ licenses:
|
|
136
66
|
- MIT
|
137
67
|
metadata:
|
138
68
|
bug_tracker_uri: https://github.com/Shopify/bootsnap/issues
|
139
|
-
changelog_uri: https://github.com/Shopify/bootsnap/blob/
|
69
|
+
changelog_uri: https://github.com/Shopify/bootsnap/blob/main/CHANGELOG.md
|
140
70
|
source_code_uri: https://github.com/Shopify/bootsnap
|
141
71
|
allowed_push_host: https://rubygems.org
|
142
72
|
post_install_message:
|