bootsnap 1.9.3 → 1.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8741381213652a6e3fc633bb87c69446d65ded8ccc5dcf72e64a8fa4a796955b
4
- data.tar.gz: e72c311d1417b7c4d174c5b95cc6d95b1b0078dfd5dfb71c213f6704cd011665
3
+ metadata.gz: 7602567343afc549df266a1b3def7e8c1e755b03a9ce486d17bba7051e97dfda
4
+ data.tar.gz: 607abfa5738cb016172bba2eb94af48b80b9e73dddea1090be77b7ca7d9f121d
5
5
  SHA512:
6
- metadata.gz: 804f427e8dd71b5aab1fe772f0f44f9fd8598cd2cd9bfc2348a13bff85fb1d65f59711188ca52b8dabc26e688655b4565e2aca2b2b8bf2a85e2635a299fe2f3a
7
- data.tar.gz: a679ccfd21df451edf3e77c750f92388ab746afbb5e5d84e3265e8e2fbd52f6c17d6a303efc179e24fa994de95762d30e2b31683517d500236fe0c2ba5f23d25
6
+ metadata.gz: 7effd658adb07d075cfbc883f47382c23f774a872fcfa2daa0b137ff5f903057a1f825a90cd96cd5784a2e72fcb583ce05b4fcf98201a2a2cb6830c90109e096
7
+ data.tar.gz: ed2f42c2e5e91c373c8882fbe17abfab93c43e6ab39b83a7aa3031d6dba48088da9c3a271b52bbb7bc83ace117d677ec25e4865936972d939a00b08580f5e45e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Unreleased
2
2
 
3
+ # 1.9.4
4
+
5
+ * Ignore absolute paths in the loaded feature index. (#385)
6
+ This fixes a compatibility issue with Zeitwerk when Zeitwerk is loaded before bootsnap. It also should
7
+ reduce the memory usage and improve load performance of Zeitwerk managed files.
8
+
9
+ * Automatically invalidate the load path cache whenever the Ruby version change. (#387)
10
+ This is to avoid issues in case the same installation path is re-used for subsequent ruby patch releases.
11
+
3
12
  # 1.9.3
4
13
 
5
14
  * Only disable the compile cache for source files impacted by [Ruby 3.0.3 [Bug 18250]](https://bugs.ruby-lang.org/issues/18250).
@@ -48,7 +48,7 @@ module Bootsnap
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
+ return feature if Bootsnap.absolute_path?(feature)
52
52
 
53
53
  if feature.start_with?('./', '../')
54
54
  return try_extensions ? expand_path(feature) : File.expand_path(feature).freeze
@@ -98,16 +98,6 @@ module Bootsnap
98
98
  raise(LoadPathCache::FallbackScan, '', []) if @development_mode
99
99
  end
100
100
 
101
- if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
102
- def absolute_path?(path)
103
- path[1] == ':'
104
- end
105
- else
106
- def absolute_path?(path)
107
- path.start_with?(SLASH)
108
- end
109
- end
110
-
111
101
  def unshift_paths(sender, *paths)
112
102
  return unless sender == @path_obj
113
103
  @mutex.synchronize { unshift_paths_locked(*paths) }
@@ -83,6 +83,11 @@ module Bootsnap
83
83
  # 2. Inspect $LOADED_FEATURES upon return from yield to find the matching
84
84
  # entry.
85
85
  def register(short, long = nil)
86
+ # Absolute paths are not a concern.
87
+ if Bootsnap.absolute_path?(short.to_s)
88
+ return yield
89
+ end
90
+
86
91
  if long.nil?
87
92
  len = $LOADED_FEATURES.size
88
93
  ret = yield
@@ -7,6 +7,9 @@ Bootsnap::ExplicitRequire.from_rubylibdir('fileutils')
7
7
  module Bootsnap
8
8
  module LoadPathCache
9
9
  class Store
10
+ VERSION_KEY = '__bootsnap_ruby_version__'
11
+ CURRENT_VERSION = "#{RUBY_REVISION}-#{RUBY_PLATFORM}".freeze
12
+
10
13
  NestedTransactionError = Class.new(StandardError)
11
14
  SetOutsideTransactionNotAllowed = Class.new(StandardError)
12
15
 
@@ -62,15 +65,20 @@ module Bootsnap
62
65
 
63
66
  def load_data
64
67
  @data = begin
65
- File.open(@store_path, encoding: Encoding::BINARY) do |io|
68
+ data = File.open(@store_path, encoding: Encoding::BINARY) do |io|
66
69
  MessagePack.load(io)
67
70
  end
71
+ if data.is_a?(Hash) && data[VERSION_KEY] == CURRENT_VERSION
72
+ data
73
+ else
74
+ default_data
75
+ end
68
76
  # handle malformed data due to upgrade incompatibility
69
77
  rescue Errno::ENOENT, MessagePack::MalformedFormatError, MessagePack::UnknownExtTypeError, EOFError
70
- {}
78
+ default_data
71
79
  rescue ArgumentError => error
72
80
  if error.message =~ /negative array size/
73
- {}
81
+ default_data
74
82
  else
75
83
  raise
76
84
  end
@@ -93,6 +101,10 @@ module Bootsnap
93
101
  retry
94
102
  rescue SystemCallError
95
103
  end
104
+
105
+ def default_data
106
+ { VERSION_KEY => CURRENT_VERSION }
107
+ end
96
108
  end
97
109
  end
98
110
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Bootsnap
3
- VERSION = "1.9.3"
3
+ VERSION = "1.9.4"
4
4
  end
data/lib/bootsnap.rb CHANGED
@@ -123,4 +123,14 @@ module Bootsnap
123
123
  end
124
124
  end
125
125
  end
126
+
127
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
128
+ def self.absolute_path?(path)
129
+ path[1] == ':'
130
+ end
131
+ else
132
+ def self.absolute_path?(path)
133
+ path.start_with?('/')
134
+ end
135
+ end
126
136
  end
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.3
4
+ version: 1.9.4
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-24 00:00:00.000000000 Z
11
+ date: 2022-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler