bootsnap 1.7.4 → 1.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5f10210480d5f0c9574fe970766d9ef4799e9a8a212f6ccafab6a61c2189481
4
- data.tar.gz: 3502a4a6f2ab2614f470d1aaa4d648ec86ab0aebe9390074a71fc1b7544a9d1c
3
+ metadata.gz: a12930656b479ba9d0675f13bf1edd2a52e0d84314f1e528866110a1a36776df
4
+ data.tar.gz: 33f4c8ea77733e461c9fe95ba75110e9da0b707e818727ebf5c13605d58eec62
5
5
  SHA512:
6
- metadata.gz: 53975108838cdfe27d2b8c9e7b0ef1a25100e85ad691063d2dfd35e6db600bf5c76591aeaf51117651fab7c96779c6877a86984bfa97eb7152afecbd42d77828
7
- data.tar.gz: 294d0cf74421f374dfde4bc551cdcb3a4f6dd4a971c0d50f3f03eb59c73ae75554689077af0cdc85aa7765aa8944e8e3edd919380fcfea9742bf7391d54756a8
6
+ metadata.gz: c366c8c65f4ce3fd73979b68c1201c2d7872d059a71ac79a561bc464b7fdaf1d0ba00acbe59e491d25d66efe967b3c0a25a9542727a43c101c4d2b719b82407c
7
+ data.tar.gz: 39d2ec6734c6234114c27f8665efe8a6170e6bcc58f98cec25f1c4386a644d0eec135ababc66b771dc0744c7df961f63d95669ebdb08db14c3b4982b320b5224
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Unreleased
2
2
 
3
+ # 1.8.0
4
+
5
+ * Improve support for Pysch 4. (#368)
6
+
7
+ # 1.7.7
8
+
9
+ * Fix `require_relative` in evaled code on latest ruby 3.1.0-dev. (#366)
10
+
11
+ # 1.7.6
12
+
13
+ * Fix reliance on `set` to be required.
14
+ * Fix `Encoding::UndefinedConversionError` error for Rails applications when precompiling cache. (#364)
15
+
16
+ # 1.7.5
17
+
18
+ * Handle a regression of Ruby 2.7.3 causing Bootsnap to call the deprecated `untaint` method. (#360)
19
+ * Gracefully handle read-only file system as well as other errors preventing to persist the load path cache. (#358)
20
+
3
21
  # 1.7.4
4
22
 
5
23
  * Stop raising errors when encoutering various file system errors. The cache is now best effort,
@@ -37,7 +37,11 @@ module Bootsnap
37
37
 
38
38
  def initialize(jobs)
39
39
  @jobs = jobs
40
- @pipe_out, @to_io = IO.pipe
40
+ @pipe_out, @to_io = IO.pipe(binmode: true)
41
+ # Set the writer encoding to binary since IO.pipe only sets it for the reader.
42
+ # https://github.com/rails/rails/issues/16514#issuecomment-52313290
43
+ @to_io.set_encoding(Encoding::BINARY)
44
+
41
45
  @pid = nil
42
46
  end
43
47
 
@@ -23,7 +23,7 @@ module Bootsnap
23
23
  end
24
24
 
25
25
  def input_to_output(data, kwargs)
26
- ::YAML.load(data, **(kwargs || {}))
26
+ ::YAML.unsafe_load(data, **(kwargs || {}))
27
27
  end
28
28
 
29
29
  def strict_load(payload, *args)
@@ -52,6 +52,13 @@ module Bootsnap
52
52
  require('msgpack')
53
53
  require('date')
54
54
 
55
+ if Patch.method_defined?(:unsafe_load_file) && !::YAML.respond_to?(:unsafe_load_file)
56
+ Patch.send(:remove_method, :unsafe_load_file)
57
+ end
58
+ if Patch.method_defined?(:load_file) && ::YAML::VERSION >= '4'
59
+ Patch.send(:remove_method, :load_file)
60
+ end
61
+
55
62
  # MessagePack serializes symbols as strings by default.
56
63
  # We want them to roundtrip cleanly, so we use a custom factory.
57
64
  # see: https://github.com/msgpack/msgpack-ruby/pull/122
@@ -126,6 +133,27 @@ module Bootsnap
126
133
  end
127
134
 
128
135
  ruby2_keywords :load_file if respond_to?(:ruby2_keywords, true)
136
+
137
+ def unsafe_load_file(path, *args)
138
+ return super if args.size > 1
139
+ if kwargs = args.first
140
+ return super unless kwargs.is_a?(Hash)
141
+ return super unless (kwargs.keys - ::Bootsnap::CompileCache::YAML.supported_options).empty?
142
+ end
143
+
144
+ begin
145
+ ::Bootsnap::CompileCache::Native.fetch(
146
+ Bootsnap::CompileCache::YAML.cache_dir,
147
+ File.realpath(path),
148
+ ::Bootsnap::CompileCache::YAML,
149
+ kwargs,
150
+ )
151
+ rescue Errno::EACCES
152
+ ::Bootsnap::CompileCache.permission_error(path)
153
+ end
154
+ end
155
+
156
+ ruby2_keywords :unsafe_load_file if respond_to?(:ruby2_keywords, true)
129
157
  end
130
158
  end
131
159
  end
@@ -196,7 +196,7 @@ module Bootsnap
196
196
 
197
197
  s = rand.to_s.force_encoding(Encoding::US_ASCII).freeze
198
198
  if s.respond_to?(:-@)
199
- if (-s).equal?(s) && (-s.dup).equal?(s)
199
+ if (-s).equal?(s) && (-s.dup).equal?(s) || RUBY_VERSION >= '2.7'
200
200
  def try_index(f)
201
201
  if (p = @index[f])
202
202
  -(File.join(p, f).freeze)
@@ -15,11 +15,13 @@ module Bootsnap
15
15
  @lpc_observer.push_paths(self, *entries.map(&:to_s))
16
16
  super
17
17
  end
18
+ alias_method :append, :push
18
19
 
19
20
  def unshift(*entries)
20
21
  @lpc_observer.unshift_paths(self, *entries.map(&:to_s))
21
22
  super
22
23
  end
24
+ alias_method :prepend, :unshift
23
25
 
24
26
  def concat(entries)
25
27
  @lpc_observer.push_paths(self, *entries.map(&:to_s))
@@ -47,8 +47,9 @@ module Kernel
47
47
 
48
48
  alias_method(:require_relative_without_bootsnap, :require_relative)
49
49
  def require_relative(path)
50
+ location = caller_locations(1..1).first
50
51
  realpath = Bootsnap::LoadPathCache.realpath_cache.call(
51
- caller_locations(1..1).first.absolute_path, path
52
+ location.absolute_path || location.path, path
52
53
  )
53
54
  require(realpath)
54
55
  end
@@ -58,9 +58,9 @@ module Bootsnap
58
58
  end
59
59
 
60
60
  def purge_multi(features)
61
- rejected_hashes = features.map(&:hash).to_set
61
+ rejected_hashes = features.each_with_object({}) { |f, h| h[f.hash] = true }
62
62
  @mutex.synchronize do
63
- @lfi.reject! { |_, hash| rejected_hashes.include?(hash) }
63
+ @lfi.reject! { |_, hash| rejected_hashes.key?(hash) }
64
64
  end
65
65
  end
66
66
 
@@ -91,6 +91,7 @@ module Bootsnap
91
91
  FileUtils.mv(tmp, @store_path)
92
92
  rescue Errno::EEXIST
93
93
  retry
94
+ rescue SystemCallError
94
95
  end
95
96
  end
96
97
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Bootsnap
3
- VERSION = "1.7.4"
3
+ VERSION = "1.8.0"
4
4
  end
data/lib/bootsnap.rb CHANGED
@@ -27,7 +27,9 @@ module Bootsnap
27
27
 
28
28
  def self.instrumentation=(callback)
29
29
  @instrumentation = callback
30
- self.instrumentation_enabled = !!callback
30
+ if respond_to?(:instrumentation_enabled=, true)
31
+ self.instrumentation_enabled = !!callback
32
+ end
31
33
  end
32
34
 
33
35
  def self._instrument(event, path)
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.7.4
4
+ version: 1.8.0
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-04-21 00:00:00.000000000 Z
11
+ date: 2021-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: rake-compiler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.0.3
156
+ rubygems_version: 3.2.20
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Boot large ruby/rails apps faster