bootsnap 1.21.1 → 1.22.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: 4ca69038da7071534a7279f36d694ec5bcf5687272d091b314372b1f3195831b
4
- data.tar.gz: c5dc747c2c66a71881d99af980085c06bfc378134d25712c51221b7fb6a6c03a
3
+ metadata.gz: 1ab247855b4e6a35b2db80b44f2d3da184fd9780e9a4faa3d35d952e15398839
4
+ data.tar.gz: c8fd54ed988e11df7e934e9ff4f30f7dfb6440b4b9a2ecd2eaf3dbf9aefa61fd
5
5
  SHA512:
6
- metadata.gz: 9da2aa5050b26d377f46d1de5e8424168e0a60b00160d43ebdaf9f93c4a9006931bf6463a24afa6dd76559ccedc4ce3798d48733d5000a7a5eac08d7c7a03510
7
- data.tar.gz: 17a8da7a372189c22f400f5c059947f98c6aa7836390965c92e6e173970a61e2e6aa57d77d3dd11a9ecea0afd729512a115fd38a21c7a30850d1e9bd662b7d26
6
+ metadata.gz: 4a7225b866cbe788281af91aa690c75191e19bc09f4d8695a58557e024193d4b0924bbf9892cbb84dad93658eda9ff46c609b113c0b588660ac318e0b9176f1f
7
+ data.tar.gz: cadb844c862e9185befec65d7fa53beb6940945ebbddbea48ab30fd22b88f19aa773baa856c414522f5acf1a1c2a8aeafa75d72fb5a86cde5ebc8557172d049c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Unreleased
2
2
 
3
+ # 1.22.0
4
+
5
+ * Better fix for the `opendir` crash.
6
+ * Add `bootsnap/rake` for cleaning the bootsnap cache as part of `rake clobber`.
7
+
3
8
  # 1.21.1
4
9
 
5
10
  * Prevent a Ruby crash while scanning load path if `opendir` fails without setting `errno`.
@@ -176,26 +176,16 @@ bs_rb_scan_dir(VALUE self, VALUE abspath)
176
176
  {
177
177
  Check_Type(abspath, T_STRING);
178
178
 
179
- DIR *dirp = opendir(RSTRING_PTR(abspath));
180
-
181
179
  VALUE dirs = rb_ary_new();
182
180
  VALUE requirables = rb_ary_new();
183
181
  VALUE result = rb_ary_new_from_args(2, requirables, dirs);
184
182
 
183
+ DIR *dirp = opendir(RSTRING_PTR(abspath));
185
184
  if (dirp == NULL) {
186
185
  if (errno == ENOTDIR || errno == ENOENT) {
187
186
  return result;
188
187
  }
189
188
 
190
- // BUG: Some users reported a crash here because Ruby's syserr trigger
191
- // a crash if called with `errno == 0`.
192
- // The opendir spec is quite clear that if it returns NULL, then `errno` must
193
- // be set, and yet here we are.
194
- // So turning no errno into EINVAL, and from there I hope to get to the bottom of things.
195
- if (errno == 0) {
196
- errno = EINVAL;
197
- }
198
-
199
189
  bs_syserr_fail_path("opendir", errno, abspath);
200
190
  return Qundef;
201
191
  }
@@ -102,13 +102,6 @@ module Bootsnap
102
102
  end
103
103
 
104
104
  all_requirables
105
- rescue SystemCallError => error
106
- if ENV["BOOTSNAP_DEBUG"]
107
- raise
108
- else
109
- Bootsnap.logger&.call("Unexpected error: #{error.class}: #{error.message}")
110
- ruby_call(root_path)
111
- end
112
105
  end
113
106
  alias_method :call, :native_call
114
107
  else
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bootsnap"
4
+ require "rake/clean"
5
+
6
+ # Typically, should have been set up prior to requiring rake integration.
7
+ # But allow for a streamlined ::default_setup
8
+ require "bootsnap/setup" if Bootsnap.cache_dir.nil?
9
+
10
+ if Bootsnap.cache_dir
11
+ CLEAN.include Bootsnap.cache_dir
12
+ else
13
+ abort "Bootsnap must be set-up prior to rake integration"
14
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bootsnap
4
- VERSION = "1.21.1"
4
+ VERSION = "1.22.0"
5
5
  end
data/lib/bootsnap.rb CHANGED
@@ -7,7 +7,7 @@ module Bootsnap
7
7
  InvalidConfiguration = Class.new(StandardError)
8
8
 
9
9
  class << self
10
- attr_reader :logger
10
+ attr_reader :cache_dir, :logger
11
11
 
12
12
  def log_stats!
13
13
  stats = {hit: 0, revalidated: 0, miss: 0, stale: 0}
@@ -58,9 +58,11 @@ module Bootsnap
58
58
  warn("Bootsnap.setup `compile_cache_json` argument is deprecated and has no effect")
59
59
  end
60
60
 
61
+ @cache_dir = "#{cache_dir}/bootsnap"
62
+
61
63
  if load_path_cache
62
64
  Bootsnap::LoadPathCache.setup(
63
- cache_path: "#{cache_dir}/bootsnap/load-path-cache",
65
+ cache_path: "#{@cache_dir}/load-path-cache",
64
66
  development_mode: development_mode,
65
67
  ignore_directories: ignore_directories,
66
68
  readonly: readonly,
@@ -68,7 +70,7 @@ module Bootsnap
68
70
  end
69
71
 
70
72
  Bootsnap::CompileCache.setup(
71
- cache_dir: "#{cache_dir}/bootsnap/compile-cache",
73
+ cache_dir: "#{@cache_dir}/compile-cache",
72
74
  iseq: compile_cache_iseq,
73
75
  yaml: compile_cache_yaml,
74
76
  readonly: readonly,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootsnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.1
4
+ version: 1.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burke Libbey
@@ -55,6 +55,7 @@ files:
55
55
  - lib/bootsnap/load_path_cache/path.rb
56
56
  - lib/bootsnap/load_path_cache/path_scanner.rb
57
57
  - lib/bootsnap/load_path_cache/store.rb
58
+ - lib/bootsnap/rake.rb
58
59
  - lib/bootsnap/setup.rb
59
60
  - lib/bootsnap/version.rb
60
61
  homepage: https://github.com/rails/bootsnap