bundler 2.2.6 → 2.2.11

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.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +65 -0
  3. data/lib/bundler.rb +1 -1
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli.rb +1 -0
  6. data/lib/bundler/cli/cache.rb +1 -0
  7. data/lib/bundler/cli/gem.rb +12 -0
  8. data/lib/bundler/definition.rb +16 -25
  9. data/lib/bundler/feature_flag.rb +0 -1
  10. data/lib/bundler/fetcher.rb +0 -1
  11. data/lib/bundler/gem_helper.rb +8 -6
  12. data/lib/bundler/index.rb +6 -5
  13. data/lib/bundler/installer.rb +0 -17
  14. data/lib/bundler/installer/standalone.rb +15 -0
  15. data/lib/bundler/lazy_specification.rb +9 -18
  16. data/lib/bundler/man/bundle-add.1 +1 -1
  17. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  18. data/lib/bundler/man/bundle-cache.1 +1 -1
  19. data/lib/bundler/man/bundle-check.1 +1 -1
  20. data/lib/bundler/man/bundle-clean.1 +1 -1
  21. data/lib/bundler/man/bundle-config.1 +8 -8
  22. data/lib/bundler/man/bundle-config.1.ronn +11 -10
  23. data/lib/bundler/man/bundle-doctor.1 +1 -1
  24. data/lib/bundler/man/bundle-exec.1 +1 -1
  25. data/lib/bundler/man/bundle-gem.1 +1 -1
  26. data/lib/bundler/man/bundle-info.1 +1 -1
  27. data/lib/bundler/man/bundle-init.1 +1 -1
  28. data/lib/bundler/man/bundle-inject.1 +1 -1
  29. data/lib/bundler/man/bundle-install.1 +1 -1
  30. data/lib/bundler/man/bundle-list.1 +1 -1
  31. data/lib/bundler/man/bundle-lock.1 +1 -1
  32. data/lib/bundler/man/bundle-open.1 +1 -1
  33. data/lib/bundler/man/bundle-outdated.1 +1 -1
  34. data/lib/bundler/man/bundle-platform.1 +1 -1
  35. data/lib/bundler/man/bundle-pristine.1 +1 -1
  36. data/lib/bundler/man/bundle-remove.1 +1 -1
  37. data/lib/bundler/man/bundle-show.1 +1 -1
  38. data/lib/bundler/man/bundle-update.1 +1 -1
  39. data/lib/bundler/man/bundle-viz.1 +1 -1
  40. data/lib/bundler/man/bundle.1 +1 -1
  41. data/lib/bundler/man/gemfile.5 +1 -1
  42. data/lib/bundler/resolver.rb +79 -45
  43. data/lib/bundler/resolver/spec_group.rb +54 -42
  44. data/lib/bundler/settings.rb +1 -1
  45. data/lib/bundler/shared_helpers.rb +2 -2
  46. data/lib/bundler/source/git.rb +1 -1
  47. data/lib/bundler/source/rubygems.rb +0 -1
  48. data/lib/bundler/source_list.rb +2 -4
  49. data/lib/bundler/spec_set.rb +4 -3
  50. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  51. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  52. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -1
  53. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  54. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +2 -2
  55. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +11 -0
  56. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +1 -1
  57. data/lib/bundler/vendor/thor/lib/thor.rb +5 -6
  58. data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
  59. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
  60. data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
  61. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  62. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
  63. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
  64. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  65. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  66. data/lib/bundler/version.rb +1 -1
  67. metadata +4 -3
@@ -3,28 +3,37 @@
3
3
  module Bundler
4
4
  class Resolver
5
5
  class SpecGroup
6
- include GemHelpers
7
-
8
6
  attr_accessor :name, :version, :source
9
- attr_accessor :ignores_bundler_dependencies, :activated_platforms
7
+ attr_accessor :activated_platforms
8
+
9
+ def self.create_for(specs, all_platforms, specific_platform)
10
+ specific_platform_specs = specs[specific_platform]
11
+ return unless specific_platform_specs.any?
12
+
13
+ platforms = all_platforms.select {|p| specs[p].any? }
14
+
15
+ new(specific_platform_specs.first, specs, platforms)
16
+ end
10
17
 
11
- def initialize(all_specs)
12
- @all_specs = all_specs
13
- raise ArgumentError, "cannot initialize with an empty value" unless exemplary_spec = all_specs.first
18
+ def initialize(exemplary_spec, specs, relevant_platforms)
19
+ @exemplary_spec = exemplary_spec
14
20
  @name = exemplary_spec.name
15
21
  @version = exemplary_spec.version
16
22
  @source = exemplary_spec.source
17
23
 
18
- @activated_platforms = []
19
- @dependencies = nil
20
- @specs = Hash.new do |specs, platform|
21
- specs[platform] = select_best_platform_match(all_specs, platform)
24
+ @all_platforms = relevant_platforms
25
+ @activated_platforms = relevant_platforms
26
+ @dependencies = Hash.new do |dependencies, platforms|
27
+ dependencies[platforms] = dependencies_for(platforms)
22
28
  end
23
- @ignores_bundler_dependencies = true
29
+ @partitioned_dependency_names = Hash.new do |partitioned_dependency_names, platforms|
30
+ partitioned_dependency_names[platforms] = partitioned_dependency_names_for(platforms)
31
+ end
32
+ @specs = specs
24
33
  end
25
34
 
26
35
  def to_specs
27
- @activated_platforms.map do |p|
36
+ activated_platforms.map do |p|
28
37
  specs = @specs[p]
29
38
  next unless specs.any?
30
39
 
@@ -36,18 +45,12 @@ module Bundler
36
45
  end.flatten.compact.uniq
37
46
  end
38
47
 
39
- def copy_for(platforms)
40
- platforms.select! {|p| for?(p) }
41
- return unless platforms.any?
42
-
43
- copied_sg = self.class.new(@all_specs)
44
- copied_sg.ignores_bundler_dependencies = @ignores_bundler_dependencies
45
- copied_sg.activated_platforms = platforms
46
- copied_sg
48
+ def activate_platform!(platform)
49
+ self.activated_platforms = [platform]
47
50
  end
48
51
 
49
- def for?(platform)
50
- @specs[platform].any?
52
+ def activate_all_platforms!
53
+ self.activated_platforms = @all_platforms
51
54
  end
52
55
 
53
56
  def to_s
@@ -56,11 +59,11 @@ module Bundler
56
59
  end
57
60
 
58
61
  def dependencies_for_activated_platforms
59
- dependencies = @activated_platforms.map {|p| __dependencies[p] }
60
- metadata_dependencies = @activated_platforms.map do |platform|
61
- metadata_dependencies(@specs[platform].first, platform)
62
- end
63
- dependencies.concat(metadata_dependencies).flatten
62
+ @dependencies[activated_platforms]
63
+ end
64
+
65
+ def partitioned_dependency_names_for_activated_platforms
66
+ @partitioned_dependency_names[activated_platforms]
64
67
  end
65
68
 
66
69
  def ==(other)
@@ -86,28 +89,37 @@ module Bundler
86
89
  protected
87
90
 
88
91
  def sorted_activated_platforms
89
- @activated_platforms.sort_by(&:to_s)
92
+ activated_platforms.sort_by(&:to_s)
90
93
  end
91
94
 
92
95
  private
93
96
 
94
- def __dependencies
95
- @dependencies = Hash.new do |dependencies, platform|
96
- dependencies[platform] = []
97
- specs = @specs[platform]
98
- if spec = specs.first
99
- spec.dependencies.each do |dep|
100
- next if dep.type == :development
101
- next if @ignores_bundler_dependencies && dep.name == "bundler".freeze
102
- dependencies[platform] << DepProxy.get_proxy(dep, platform)
103
- end
104
- end
105
- dependencies[platform]
97
+ def dependencies_for(platforms)
98
+ platforms.map do |platform|
99
+ __dependencies(platform) + metadata_dependencies(platform)
100
+ end.flatten
101
+ end
102
+
103
+ def partitioned_dependency_names_for(platforms)
104
+ return @dependencies[platforms].map(&:name), [] if platforms.size == 1
105
+
106
+ @dependencies[platforms].partition do |dep_proxy|
107
+ @dependencies[platforms].count {|dp| dp.dep == dep_proxy.dep } == platforms.size
108
+ end.map {|deps| deps.map(&:name) }
109
+ end
110
+
111
+ def __dependencies(platform)
112
+ dependencies = []
113
+ @specs[platform].first.dependencies.each do |dep|
114
+ next if dep.type == :development
115
+ dependencies << DepProxy.get_proxy(dep, platform)
106
116
  end
117
+ dependencies
107
118
  end
108
119
 
109
- def metadata_dependencies(spec, platform)
110
- return [] unless spec && spec.is_a?(Gem::Specification)
120
+ def metadata_dependencies(platform)
121
+ spec = @specs[platform].first
122
+ return [] unless spec.is_a?(Gem::Specification)
111
123
  dependencies = []
112
124
  if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
113
125
  dependencies << DepProxy.get_proxy(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
@@ -7,7 +7,6 @@ module Bundler
7
7
  autoload :Validator, File.expand_path("settings/validator", __dir__)
8
8
 
9
9
  BOOL_KEYS = %w[
10
- allow_bundler_dependency_conflicts
11
10
  allow_deployment_source_credential_changes
12
11
  allow_offline_install
13
12
  auto_clean_without_path
@@ -20,6 +19,7 @@ module Bundler
20
19
  disable_checksum_validation
21
20
  disable_exec_load
22
21
  disable_local_branch_check
22
+ disable_local_revision_check
23
23
  disable_multisource
24
24
  disable_shared_gems
25
25
  disable_version_check
@@ -194,11 +194,11 @@ module Bundler
194
194
  return @md5_available if defined?(@md5_available)
195
195
  @md5_available = begin
196
196
  require "openssl"
197
- OpenSSL::Digest.digest("MD5", "")
197
+ ::OpenSSL::Digest.digest("MD5", "")
198
198
  true
199
199
  rescue LoadError
200
200
  true
201
- rescue OpenSSL::Digest::DigestError
201
+ rescue ::OpenSSL::Digest::DigestError
202
202
  false
203
203
  end
204
204
  end
@@ -148,7 +148,7 @@ module Bundler
148
148
 
149
149
  changed = cached_revision && cached_revision != git_proxy.revision
150
150
 
151
- if changed && !@unlocked && !git_proxy.contains?(cached_revision)
151
+ if !Bundler.settings[:disable_local_revision_check] && changed && !@unlocked && !git_proxy.contains?(cached_revision)
152
152
  raise GitError, "The Gemfile lock is pointing to revision #{shortref_for_display(cached_revision)} " \
153
153
  "but the current branch in your local override for #{name} does not contain such commit. " \
154
154
  "Please make sure your branch is up to date."
@@ -353,7 +353,6 @@ module Bundler
353
353
  def installed_specs
354
354
  @installed_specs ||= Index.build do |idx|
355
355
  Bundler.rubygems.all_specs.reverse_each do |spec|
356
- next if spec.name == "bundler"
357
356
  spec.source = self
358
357
  if Bundler.rubygems.spec_missing_extensions?(spec, false)
359
358
  Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions"
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "set"
4
-
5
3
  module Bundler
6
4
  class SourceList
7
5
  attr_reader :path_sources,
@@ -99,7 +97,7 @@ module Bundler
99
97
  @rubygems_aggregate = replacement_rubygems if replacement_rubygems
100
98
 
101
99
  return true if !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
102
- return true if replacement_rubygems && rubygems_remotes.to_set != replacement_rubygems.remotes.to_set
100
+ return true if replacement_rubygems && rubygems_remotes.sort_by(&:to_s) != replacement_rubygems.remotes.sort_by(&:to_s)
103
101
 
104
102
  false
105
103
  end
@@ -153,7 +151,7 @@ module Bundler
153
151
  end
154
152
 
155
153
  def equal_sources?(lock_sources, replacement_sources)
156
- lock_sources.to_set == replacement_sources.to_set
154
+ lock_sources.sort_by(&:to_s) == replacement_sources.sort_by(&:to_s)
157
155
  end
158
156
 
159
157
  def equal_source?(source, other_source)
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "tsort"
4
- require "set"
5
4
 
6
5
  module Bundler
7
6
  class SpecSet
@@ -13,14 +12,16 @@ module Bundler
13
12
  end
14
13
 
15
14
  def for(dependencies, skip = [], check = false, match_current_platform = false, raise_on_missing = true)
16
- handled = Set.new
15
+ handled = []
17
16
  deps = dependencies.dup
18
17
  specs = []
19
18
  skip += ["bundler"]
20
19
 
21
20
  loop do
22
21
  break unless dep = deps.shift
23
- next if !handled.add?(dep) || skip.include?(dep.name)
22
+ next if handled.include?(dep) || skip.include?(dep.name)
23
+
24
+ handled << dep
24
25
 
25
26
  specs_for_dep = spec_for_dependency(dep, match_current_platform)
26
27
  if specs_for_dep.any?
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - <%= Time.now.strftime('%F') %>
4
+
5
+ - Initial release
@@ -26,6 +26,13 @@ module Bundler::Molinillo
26
26
  end
27
27
  end
28
28
 
29
+ # (see Bundler::Molinillo::SpecificationProvider#dependencies_equal?)
30
+ def dependencies_equal?(dependencies, other_dependencies)
31
+ with_no_such_dependency_error_handling do
32
+ specification_provider.dependencies_equal?(dependencies, other_dependencies)
33
+ end
34
+ end
35
+
29
36
  # (see Bundler::Molinillo::SpecificationProvider#name_for)
30
37
  def name_for(dependency)
31
38
  with_no_such_dependency_error_handling do
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
3
  require 'tsort'
5
4
 
6
5
  require_relative 'dependency_graph/log'
@@ -59,7 +59,7 @@ module Bundler::Molinillo
59
59
  # @param [Set<Vertex>] vertices the set to add the predecessors to
60
60
  # @return [Set<Vertex>] the vertices of {#graph} where `self` is a
61
61
  # {#descendent?}
62
- def _recursive_predecessors(vertices = Set.new)
62
+ def _recursive_predecessors(vertices = new_vertex_set)
63
63
  incoming_edges.each do |edge|
64
64
  vertex = edge.origin
65
65
  next unless vertices.add?(vertex)
@@ -85,7 +85,7 @@ module Bundler::Molinillo
85
85
  # @param [Set<Vertex>] vertices the set to add the successors to
86
86
  # @return [Set<Vertex>] the vertices of {#graph} where `self` is an
87
87
  # {#ancestor?}
88
- def _recursive_successors(vertices = Set.new)
88
+ def _recursive_successors(vertices = new_vertex_set)
89
89
  outgoing_edges.each do |edge|
90
90
  vertex = edge.destination
91
91
  next unless vertices.add?(vertex)
@@ -128,7 +128,7 @@ module Bundler::Molinillo
128
128
 
129
129
  # Is there a path from `self` to `other` following edges in the
130
130
  # dependency graph?
131
- # @return true iff there is a path following edges within this {#graph}
131
+ # @return whether there is a path following edges within this {#graph}
132
132
  def path_to?(other)
133
133
  _path_to?(other)
134
134
  end
@@ -138,7 +138,7 @@ module Bundler::Molinillo
138
138
  # @param [Vertex] other the vertex to check if there's a path to
139
139
  # @param [Set<Vertex>] visited the vertices of {#graph} that have been visited
140
140
  # @return [Boolean] whether there is a path to `other` from `self`
141
- def _path_to?(other, visited = Set.new)
141
+ def _path_to?(other, visited = new_vertex_set)
142
142
  return false unless visited.add?(self)
143
143
  return true if equal?(other)
144
144
  successors.any? { |v| v._path_to?(other, visited) }
@@ -147,12 +147,18 @@ module Bundler::Molinillo
147
147
 
148
148
  # Is there a path from `other` to `self` following edges in the
149
149
  # dependency graph?
150
- # @return true iff there is a path following edges within this {#graph}
150
+ # @return whether there is a path following edges within this {#graph}
151
151
  def ancestor?(other)
152
152
  other.path_to?(self)
153
153
  end
154
154
 
155
155
  alias is_reachable_from? ancestor?
156
+
157
+ def new_vertex_set
158
+ require 'set'
159
+ Set.new
160
+ end
161
+ private :new_vertex_set
156
162
  end
157
163
  end
158
164
  end
@@ -34,7 +34,7 @@ module Bundler::Molinillo
34
34
 
35
35
  # An error caused by attempting to fulfil a dependency that was circular
36
36
  #
37
- # @note This exception will be thrown iff a {Vertex} is added to a
37
+ # @note This exception will be thrown if and only if a {Vertex} is added to a
38
38
  # {DependencyGraph} that has a {DependencyGraph::Vertex#path_to?} an
39
39
  # existing {DependencyGraph::Vertex}
40
40
  class CircularDependencyError < ResolverError
@@ -121,7 +121,7 @@ module Bundler::Molinillo
121
121
  t = ''.dup
122
122
  depth = 2
123
123
  tree.each do |req|
124
- t << ' ' * depth << req.to_s
124
+ t << ' ' * depth << printable_requirement.call(req)
125
125
  unless tree.last == req
126
126
  if spec = conflict.activated_by_name[name_for(req)]
127
127
  t << %( was resolved to #{version_for_spec.call(spec)}, which)
@@ -45,6 +45,17 @@ module Bundler::Molinillo
45
45
  true
46
46
  end
47
47
 
48
+ # Determines whether two arrays of dependencies are equal, and thus can be
49
+ # grouped.
50
+ #
51
+ # @param [Array<Object>] dependencies
52
+ # @param [Array<Object>] other_dependencies
53
+ # @return [Boolean] whether `dependencies` and `other_dependencies` should
54
+ # be considered equal.
55
+ def dependencies_equal?(dependencies, other_dependencies)
56
+ dependencies == other_dependencies
57
+ end
58
+
48
59
  # Returns the name for the given `dependency`.
49
60
  # @note This method should be 'pure', i.e. the return value should depend
50
61
  # only on the `dependency` parameter.
@@ -807,7 +807,7 @@ module Bundler::Molinillo
807
807
 
808
808
  possibilities.reverse_each do |possibility|
809
809
  dependencies = dependencies_for(possibility)
810
- if current_possibility_set && current_possibility_set.dependencies == dependencies
810
+ if current_possibility_set && dependencies_equal?(current_possibility_set.dependencies, dependencies)
811
811
  current_possibility_set.possibilities.unshift(possibility)
812
812
  else
813
813
  possibility_sets.unshift(PossibilitySet.new(dependencies, [possibility]))
@@ -1,7 +1,7 @@
1
- require "set"
2
1
  require_relative "thor/base"
3
2
 
4
3
  class Bundler::Thor
4
+ $thor_runner ||= false
5
5
  class << self
6
6
  # Allows for custom "Command" package naming.
7
7
  #
@@ -323,7 +323,7 @@ class Bundler::Thor
323
323
  # ==== Parameters
324
324
  # Symbol ...:: A list of commands that should be affected.
325
325
  def stop_on_unknown_option!(*command_names)
326
- stop_on_unknown_option.merge(command_names)
326
+ @stop_on_unknown_option = stop_on_unknown_option | command_names
327
327
  end
328
328
 
329
329
  def stop_on_unknown_option?(command) #:nodoc:
@@ -337,7 +337,7 @@ class Bundler::Thor
337
337
  # ==== Parameters
338
338
  # Symbol ...:: A list of commands that should be affected.
339
339
  def disable_required_check!(*command_names)
340
- disable_required_check.merge(command_names)
340
+ @disable_required_check = disable_required_check | command_names
341
341
  end
342
342
 
343
343
  def disable_required_check?(command) #:nodoc:
@@ -347,12 +347,12 @@ class Bundler::Thor
347
347
  protected
348
348
 
349
349
  def stop_on_unknown_option #:nodoc:
350
- @stop_on_unknown_option ||= Set.new
350
+ @stop_on_unknown_option ||= []
351
351
  end
352
352
 
353
353
  # help command has the required check disabled by default.
354
354
  def disable_required_check #:nodoc:
355
- @disable_required_check ||= Set.new([:help])
355
+ @disable_required_check ||= [:help]
356
356
  end
357
357
 
358
358
  # The method responsible for dispatching given the args.
@@ -398,7 +398,6 @@ class Bundler::Thor
398
398
  # the namespace should be displayed as arguments.
399
399
  #
400
400
  def banner(command, namespace = nil, subcommand = false)
401
- $thor_runner ||= false
402
401
  command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
403
402
  "#{basename} #{formatted_usage}"
404
403
  end.join("\n")
@@ -219,7 +219,7 @@ class Bundler::Thor
219
219
 
220
220
  contents = if is_uri
221
221
  require "open-uri"
222
- open(path, "Accept" => "application/x-thor-template", &:read)
222
+ URI.open(path, "Accept" => "application/x-thor-template", &:read)
223
223
  else
224
224
  open(path, &:read)
225
225
  end
@@ -251,7 +251,8 @@ class Bundler::Thor
251
251
  # path<String>:: path of the file to be changed
252
252
  # flag<Regexp|String>:: the regexp or string to be replaced
253
253
  # replacement<String>:: the replacement, can be also given as a block
254
- # config<Hash>:: give :verbose => false to not log the status.
254
+ # config<Hash>:: give :verbose => false to not log the status, and
255
+ # :force => true, to force the replacement regardles of runner behavior.
255
256
  #
256
257
  # ==== Example
257
258
  #
@@ -262,9 +263,10 @@ class Bundler::Thor
262
263
  # end
263
264
  #
264
265
  def gsub_file(path, flag, *args, &block)
265
- return unless behavior == :invoke
266
266
  config = args.last.is_a?(Hash) ? args.pop : {}
267
267
 
268
+ return unless behavior == :invoke || config.fetch(:force, false)
269
+
268
270
  path = File.expand_path(path, destination_root)
269
271
  say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
270
272