bundler 4.1.0.beta2 → 4.1.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bundler/build_metadata.rb +2 -2
  3. data/lib/bundler/checksum.rb +8 -2
  4. data/lib/bundler/cli/clean.rb +19 -3
  5. data/lib/bundler/cli/exec.rb +1 -1
  6. data/lib/bundler/cli/install.rb +1 -1
  7. data/lib/bundler/cli/lock.rb +17 -1
  8. data/lib/bundler/cli/update.rb +1 -1
  9. data/lib/bundler/cli.rb +2 -0
  10. data/lib/bundler/definition.rb +170 -12
  11. data/lib/bundler/dsl.rb +40 -23
  12. data/lib/bundler/errors.rb +8 -0
  13. data/lib/bundler/fetcher/downloader.rb +15 -5
  14. data/lib/bundler/fetcher.rb +4 -1
  15. data/lib/bundler/index.rb +7 -2
  16. data/lib/bundler/inline.rb +16 -8
  17. data/lib/bundler/installer.rb +19 -0
  18. data/lib/bundler/lazy_specification.rb +42 -25
  19. data/lib/bundler/lockfile_generator.rb +27 -9
  20. data/lib/bundler/lockfile_parser.rb +38 -6
  21. data/lib/bundler/man/bundle-lock.1 +7 -1
  22. data/lib/bundler/man/bundle-lock.1.ronn +10 -0
  23. data/lib/bundler/man/bundle-plugin.1 +61 -0
  24. data/lib/bundler/man/bundle-plugin.1.ronn +84 -0
  25. data/lib/bundler/man/gemfile.5 +21 -10
  26. data/lib/bundler/man/gemfile.5.ronn +39 -17
  27. data/lib/bundler/match_platform.rb +15 -6
  28. data/lib/bundler/mirror.rb +7 -5
  29. data/lib/bundler/override.rb +60 -7
  30. data/lib/bundler/resolver.rb +3 -1
  31. data/lib/bundler/ruby_dsl.rb +2 -1
  32. data/lib/bundler/rubygems_ext.rb +56 -13
  33. data/lib/bundler/rubygems_integration.rb +2 -4
  34. data/lib/bundler/runtime.rb +24 -10
  35. data/lib/bundler/source/git/git_proxy.rb +18 -6
  36. data/lib/bundler/source/git.rb +0 -2
  37. data/lib/bundler/source/rubygems.rb +2 -2
  38. data/lib/bundler/source_map.rb +1 -1
  39. data/lib/bundler/spec_set.rb +26 -7
  40. data/lib/bundler/stub_specification.rb +4 -0
  41. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +54 -29
  42. data/lib/bundler/version.rb +1 -1
  43. data/lib/bundler/worker.rb +4 -0
  44. data/lib/bundler.rb +1 -1
  45. data/lib/rubygems/compact_index_client/http_fetcher.rb +3 -1
  46. data/lib/rubygems/compact_index_client/parser.rb +1 -0
  47. data/lib/rubygems/vendor/uri/lib/uri/common.rb +1 -1
  48. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +15 -3
  49. data/lib/rubygems/vendor/uri/lib/uri/version.rb +1 -1
  50. data/lib/rubygems/yaml_serializer.rb +247 -137
  51. metadata +2 -2
@@ -169,13 +169,25 @@ module Bundler
169
169
  git "fetch", "--force", "--quiet", *extra_fetch_args(ref), dir: destination
170
170
  end
171
171
 
172
- git "reset", "--hard", revision, dir: destination
172
+ # A checkout that already had a working tree may be a local override, which
173
+ # is the user's own working copy, so a failure only discards one that had none.
174
+ checked_out = installed_to?(destination)
175
+ begin
176
+ git "reset", "--hard", revision, dir: destination
173
177
 
174
- if submodules
175
- git_retry "submodule", "update", "--init", "--recursive", dir: destination
176
- elsif Gem::Version.create(version) >= Gem::Version.create("2.9.0")
177
- inner_command = "git -C $toplevel submodule deinit --force $sm_path"
178
- git_retry "submodule", "foreach", "--quiet", inner_command, dir: destination
178
+ if submodules
179
+ git_retry "submodule", "update", "--init", "--recursive", dir: destination
180
+ elsif Gem::Version.create(version) >= Gem::Version.create("2.9.0")
181
+ inner_command = "git -C $toplevel submodule deinit --force $sm_path"
182
+ git_retry "submodule", "foreach", "--quiet", inner_command, dir: destination
183
+ end
184
+ rescue GitCommandError
185
+ unless checked_out
186
+ SharedHelpers.filesystem_access(destination) do |p|
187
+ FileUtils.rm_rf(p)
188
+ end
189
+ end
190
+ raise
179
191
  end
180
192
  end
181
193
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../vendored_fileutils"
4
-
5
3
  module Bundler
6
4
  class Source
7
5
  class Git < Path
@@ -77,11 +77,11 @@ module Bundler
77
77
  end
78
78
 
79
79
  def hash
80
- @remotes.hash
80
+ credless_remotes.hash
81
81
  end
82
82
 
83
83
  def eql?(other)
84
- other.is_a?(Rubygems) && other.credless_remotes == credless_remotes
84
+ equal?(other) || (other.is_a?(Rubygems) && other.credless_remotes == credless_remotes)
85
85
  end
86
86
 
87
87
  alias_method :==, :eql?
@@ -8,7 +8,7 @@ module Bundler
8
8
  @sources = sources
9
9
  @dependencies = dependencies
10
10
  @locked_specs = locked_specs
11
- # No gemspec names a gem that a `from:`/`to:` override substitutes, so
11
+ # No gemspec names a gem that a `with:`/`in:` override substitutes, so
12
12
  # the dependency API never fetches it unless asked.
13
13
  @replacement_names = replacement_names
14
14
  end
@@ -84,15 +84,36 @@ module Bundler
84
84
  platforms.delete(Bundler.local_platform) if less_specific_platform
85
85
  end
86
86
 
87
+ def assign_content_addresses!(ruby_abis, normalize: false, local: false)
88
+ @specs.each do |spec|
89
+ next unless spec.source.is_a?(Source::Rubygems)
90
+ next unless Gem::ContentAddress.platform_eligible?(spec.platform)
91
+
92
+ offered = spec.source.specs.search([spec.name, spec.version]).filter_map do |gem|
93
+ next unless gem.platform.to_s == spec.platform.to_s && Gem::ContentAddress.content_addressed?(gem)
94
+
95
+ [gem.content_address, Gem::ContentAddress.ruby_abi_for(gem.required_ruby_version)]
96
+ end.to_h
97
+
98
+ locked = normalize ? {} : spec.content_addresses
99
+ locked = locked.reject {|_, ruby_abi| ruby_abi.nil? } unless local
100
+ spec.content_addresses = locked.merge(offered).select {|_, ruby_abi| ruby_abi.nil? || ruby_abis.include?(ruby_abi) }
101
+ end
102
+ end
103
+
104
+ def content_addresses_cover?(ruby_abi)
105
+ @specs.all? {|spec| !spec.is_a?(LazySpecification) || spec.content_addresses.empty? || spec.content_addresses.value?(ruby_abi) }
106
+ end
107
+
87
108
  def validate_deps(s, overrides = s.is_a?(LazySpecification) ? Array(s.overrides) : [])
88
109
  Override.rewrite_dependencies(overrides, s.name, s.runtime_dependencies).each do |dep|
89
110
  next if dep.name == "bundler"
90
111
 
91
- return :missing unless names.include?(dep.name)
112
+ return :missing unless lookup.key?(dep.name)
92
113
 
93
114
  override = Override.find_for(overrides, dep.name, :version)
94
115
  dep = Gem::Dependency.new(dep.name, override.apply_to(dep.requirement)) if override
95
- return :invalid if none? {|spec| dep.matches_spec?(spec) }
116
+ return :invalid if Array(lookup[dep.name]).none? {|spec| dep.matches_spec?(spec) }
96
117
  end
97
118
 
98
119
  :valid
@@ -134,11 +155,9 @@ module Bundler
134
155
  # Materialize for all the specs in the spec set, regardless of what platform they're for
135
156
  # @return [Array<Gem::Specification>]
136
157
  def materialized_for_all_platforms
137
- @specs.map do |s|
138
- next s unless s.is_a?(LazySpecification)
139
- spec = s.materialize_for_cache
140
- raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
141
- spec
158
+ @specs.flat_map do |s|
159
+ next [s] unless s.is_a?(LazySpecification)
160
+ s.materialize_for_cache
142
161
  end
143
162
  end
144
163
 
@@ -114,6 +114,10 @@ module Bundler
114
114
  stub.matches_for_glob(glob)
115
115
  end
116
116
 
117
+ def contains_requirable_file?(file)
118
+ stub.contains_requirable_file?(file)
119
+ end
120
+
117
121
  def raw_require_paths
118
122
  stub.raw_require_paths
119
123
  end
@@ -181,7 +181,7 @@ end
181
181
  #
182
182
  module Bundler::FileUtils
183
183
  # The version number.
184
- VERSION = "1.8.0"
184
+ VERSION = "1.8.1"
185
185
 
186
186
  def self.private_module_function(name) #:nodoc:
187
187
  module_function name
@@ -279,38 +279,67 @@ module Bundler::FileUtils
279
279
  end
280
280
  private_module_function :remove_trailing_slash
281
281
 
282
+ # :markup: markdown
282
283
  #
283
- # Creates directories at the paths in the given +list+
284
- # (a single path or an array of paths);
285
- # returns +list+ if it is an array, <tt>[list]</tt> otherwise.
284
+ # call-seq:
285
+ # Bundler::FileUtils.mkdir(*paths, mode: 0775, noop: nil, verbose: nil) -> array_of_paths or nil
286
286
  #
287
- # Argument +list+ or its elements
288
- # should be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments].
287
+ # Argument `paths` may be one path or an array of paths;
288
+ # each must be {interpretable as a path}[rdoc-ref:FileUtils@Path+Arguments].
289
289
  #
290
- # With no keyword arguments, creates a directory at each +path+ in +list+
291
- # by calling: <tt>Dir.mkdir(path, mode)</tt>;
292
- # see {Dir.mkdir}[https://docs.ruby-lang.org/en/master/Dir.html#method-c-mkdir]:
290
+ # By default, creates a directory entry at each of the given `paths`;
291
+ # each directory has permissions `0775`;
292
+ # returns an array of the paths:
293
293
  #
294
- # Bundler::FileUtils.mkdir(%w[tmp0 tmp1]) # => ["tmp0", "tmp1"]
295
- # Bundler::FileUtils.mkdir('tmp4') # => ["tmp4"]
294
+ # ```ruby
295
+ # Bundler::FileUtils.mkdir('foo') # => ["foo"]
296
+ # Bundler::FileUtils.mkdir(%w[bar baz]) # => ["bar", "baz"]
297
+ # File.stat(Dir.new('foo')).mode.to_s(8) # => "40775"
298
+ # File.stat(Dir.new('bar')).mode.to_s(8) # => "40775"
299
+ # File.stat(Dir.new('baz')).mode.to_s(8) # => "40775"
300
+ # Bundler::FileUtils.rmdir(%w[foo bar baz]) # => ["foo", "bar", "baz"]
301
+ # ```
296
302
  #
297
- # Keyword arguments:
303
+ # Raises an exception if for any reason a directory cannot be created;
304
+ # a common reason is that the directory already exists.
298
305
  #
299
- # - <tt>mode: <i>mode</i></tt> - also calls <tt>File.chmod(mode, path)</tt>;
300
- # see {File.chmod}[https://docs.ruby-lang.org/en/master/File.html#method-c-chmod].
301
- # - <tt>noop: true</tt> - does not create directories.
302
- # - <tt>verbose: true</tt> - prints an equivalent command:
306
+ # With keyword argument `mode` given,
307
+ # creates directories with the given permissions:
303
308
  #
304
- # Bundler::FileUtils.mkdir(%w[tmp0 tmp1], verbose: true)
305
- # Bundler::FileUtils.mkdir(%w[tmp2 tmp3], mode: 0700, verbose: true)
309
+ # ```ruby
310
+ # Bundler::FileUtils.mkdir('bar', mode: 0664)
311
+ # File.stat(Dir.new('bar')).mode.to_s(8) # => "40664"
312
+ # Bundler::FileUtils.rmdir('bar')
313
+ # ```
306
314
  #
307
- # Output:
315
+ # With keyword argument `noop` given as `true`,
316
+ # does not create directories;
317
+ # returns `nil`
318
+ #
319
+ # ```ruby
320
+ # Bundler::FileUtils.mkdir('foo', noop: true) # => nil
321
+ # Dir.exist?('foo') # => false
322
+ # ```
323
+ #
324
+ # With keyword argument `verbose` given as `true`,
325
+ # prints a shell command:
308
326
  #
309
- # mkdir tmp0 tmp1
310
- # mkdir -m 700 tmp2 tmp3
327
+ # ```ruby
328
+ # Bundler::FileUtils.mkdir('foo', verbose: true)
329
+ # Bundler::FileUtils.mkdir(%w[bar baz], mode: 0644, verbose: true)
330
+ # Bundler::FileUtils.mkdir(%w[bar baz], mode: 0644, verbose: true, noop: true)
331
+ # ```
311
332
  #
312
- # Raises an exception if any path points to an existing
313
- # file or directory, or if for any reason a directory cannot be created.
333
+ # Output:
334
+ #
335
+ # ```text
336
+ # mkdir foo
337
+ # mkdir -m 644 bar baz
338
+ # mkdir -m 644 bar baz
339
+ # ```
340
+ #
341
+ # Note that in the last call above (containing `noop: true`)
342
+ # the existence of the directory is not checked.
314
343
  #
315
344
  # Related: Bundler::FileUtils.mkdir_p.
316
345
  #
@@ -686,7 +715,7 @@ module Bundler::FileUtils
686
715
  # Keyword arguments:
687
716
  #
688
717
  # - <tt>force: true</tt> - overwrites +dest+ if it exists.
689
- # - <tt>relative: false</tt> - create links relative to +dest+.
718
+ # - <tt>relative: true</tt> - create links relative to +dest+.
690
719
  # - <tt>noop: true</tt> - does not create links.
691
720
  # - <tt>verbose: true</tt> - prints an equivalent command:
692
721
  #
@@ -754,7 +783,7 @@ module Bundler::FileUtils
754
783
  n = real_ddirs.size - i
755
784
  n -= 1 unless target_directory
756
785
  link2 = fu_clean_components(*Array.new([n, 0].max, '..'), *real_sdirs[i..-1])
757
- link1 = link2 if link1.size > link2.size
786
+ link1 = link2 if !link2.empty? and link1.size > link2.size
758
787
  end
759
788
  s = File.join(link1)
760
789
  fu_output_message [cmd, s, d].flatten.join(' ') if verbose
@@ -2037,10 +2066,6 @@ module Bundler::FileUtils
2037
2066
  def fu_windows?; false end #:nodoc:
2038
2067
  end
2039
2068
 
2040
- def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
2041
- IO.copy_stream(src, dest)
2042
- end
2043
-
2044
2069
  def fu_stream_blksize(*streams) #:nodoc:
2045
2070
  streams.each do |s|
2046
2071
  next unless s.respond_to?(:stat)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "4.1.0.beta2".freeze
4
+ VERSION = "4.1.0".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= gem_version.segments.first
@@ -93,6 +93,10 @@ module Bundler
93
93
  end
94
94
 
95
95
  def create_threads
96
+ # Jobs use FileUtils, and TruffleRuby shows other threads an autoloaded
97
+ # constant while its file is still loading.
98
+ require_relative "vendored_fileutils"
99
+
96
100
  creation_errors = []
97
101
 
98
102
  @threads = Array.new(@size) do |i|
data/lib/bundler.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "bundler/rubygems_ext"
4
- require_relative "bundler/vendored_fileutils"
5
4
  autoload :Pathname, "pathname" unless defined?(Pathname)
6
5
  require "rbconfig"
7
6
 
@@ -43,6 +42,7 @@ module Bundler
43
42
  autoload :CIDetector, File.expand_path("bundler/ci_detector", __dir__)
44
43
  autoload :Definition, File.expand_path("bundler/definition", __dir__)
45
44
  autoload :Dependency, File.expand_path("bundler/dependency", __dir__)
45
+ autoload :FileUtils, File.expand_path("bundler/vendored_fileutils", __dir__)
46
46
  autoload :Deprecate, File.expand_path("bundler/deprecate", __dir__)
47
47
  autoload :Digest, File.expand_path("bundler/digest", __dir__)
48
48
  autoload :Dsl, File.expand_path("bundler/dsl", __dir__)
@@ -9,6 +9,8 @@ class Gem::CompactIndexClient
9
9
  # Gem::CompactIndexClient: #call(path, headers) returning a
10
10
  # Gem::Net::HTTP response.
11
11
  class HTTPFetcher
12
+ include Gem::Text
13
+
12
14
  REDIRECT_LIMIT = 10
13
15
  private_constant :REDIRECT_LIMIT
14
16
 
@@ -79,7 +81,7 @@ class Gem::CompactIndexClient
79
81
  end
80
82
 
81
83
  def bad_response(response, uri)
82
- detail = response["X-Error-Message"] || response.message
84
+ detail = clean_text(response["X-Error-Message"] || response.message)
83
85
  Gem::RemoteFetcher::FetchError.new("bad response #{detail} #{response.code}", uri)
84
86
  end
85
87
 
@@ -24,6 +24,7 @@ class Gem::CompactIndexClient
24
24
 
25
25
  lines(@compact_index.versions).each do |line|
26
26
  name, versions_string, checksum = line.split(" ", 3)
27
+ next unless versions_string # see #parse_version_checksum
27
28
  @info_checksums[name] = checksum || ""
28
29
  versions_string.split(",") do |version|
29
30
  delete = version.delete_prefix!("-")
@@ -271,7 +271,7 @@ module Gem::URI
271
271
  # # => #<Gem::URI::HTTP http://example.com/foo/bar>
272
272
  #
273
273
  def self.join(*str)
274
- DEFAULT_PARSER.join(*str)
274
+ PARSER.join(*str)
275
275
  end
276
276
 
277
277
  #
@@ -466,7 +466,7 @@ module Gem::URI
466
466
  #
467
467
  # uri = Gem::URI.parse("http://john:S3nsit1ve@my.example.com")
468
468
  # uri.user = "sam"
469
- # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
469
+ # uri.to_s #=> "http://sam@my.example.com"
470
470
  #
471
471
  def user=(user)
472
472
  check_user(user)
@@ -1021,9 +1021,21 @@ module Gem::URI
1021
1021
 
1022
1022
  # RFC2396, Section 5.2, 6), a)
1023
1023
  base_path << '' if base_path.last == '..'
1024
- while i = base_path.index('..')
1025
- base_path.slice!(i - 1, 2)
1024
+ # Remove "<segment>/.." pairs in a single left-to-right pass (O(n)).
1025
+ # This deliberately differs from the relative-path stack handling
1026
+ # below: a leading ".." (one with no preceding segment left to
1027
+ # cancel) discards the whole base path, reproducing the previous
1028
+ # index/slice! implementation exactly.
1029
+ reduced = []
1030
+ base_path.each do |seg|
1031
+ if seg == '..'
1032
+ break if reduced.empty?
1033
+ reduced.pop
1034
+ else
1035
+ reduced << seg
1036
+ end
1026
1037
  end
1038
+ base_path = reduced
1027
1039
 
1028
1040
  if (first = rel_path.first) and first.empty?
1029
1041
  base_path.clear
@@ -1,6 +1,6 @@
1
1
  module Gem::URI
2
2
  # :stopdoc:
3
- VERSION = '1.1.1'.freeze
3
+ VERSION = '1.1.2'.freeze
4
4
  VERSION_CODE = VERSION.split('.').map{|s| s.rjust(2, '0')}.join.freeze
5
5
  # :startdoc:
6
6
  end