bundler 2.2.7 → 2.2.17

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +132 -5
  3. data/lib/bundler.rb +1 -1
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli.rb +4 -2
  6. data/lib/bundler/cli/common.rb +15 -2
  7. data/lib/bundler/cli/gem.rb +43 -17
  8. data/lib/bundler/cli/outdated.rb +1 -1
  9. data/lib/bundler/compact_index_client/updater.rb +10 -6
  10. data/lib/bundler/current_ruby.rb +1 -0
  11. data/lib/bundler/definition.rb +63 -58
  12. data/lib/bundler/dsl.rb +36 -25
  13. data/lib/bundler/feature_flag.rb +0 -1
  14. data/lib/bundler/fetcher.rb +2 -1
  15. data/lib/bundler/fetcher/downloader.rb +8 -4
  16. data/lib/bundler/gem_helper.rb +16 -0
  17. data/lib/bundler/index.rb +6 -5
  18. data/lib/bundler/injector.rb +2 -2
  19. data/lib/bundler/inline.rb +2 -1
  20. data/lib/bundler/installer.rb +2 -0
  21. data/lib/bundler/installer/parallel_installer.rb +36 -15
  22. data/lib/bundler/installer/standalone.rb +2 -1
  23. data/lib/bundler/lazy_specification.rb +14 -18
  24. data/lib/bundler/lockfile_parser.rb +3 -13
  25. data/lib/bundler/man/bundle-add.1 +1 -1
  26. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  27. data/lib/bundler/man/bundle-cache.1 +1 -1
  28. data/lib/bundler/man/bundle-check.1 +1 -1
  29. data/lib/bundler/man/bundle-clean.1 +1 -1
  30. data/lib/bundler/man/bundle-config.1 +25 -8
  31. data/lib/bundler/man/bundle-config.1.ronn +29 -10
  32. data/lib/bundler/man/bundle-doctor.1 +1 -1
  33. data/lib/bundler/man/bundle-exec.1 +1 -1
  34. data/lib/bundler/man/bundle-gem.1 +1 -1
  35. data/lib/bundler/man/bundle-info.1 +1 -1
  36. data/lib/bundler/man/bundle-init.1 +1 -1
  37. data/lib/bundler/man/bundle-inject.1 +1 -1
  38. data/lib/bundler/man/bundle-install.1 +1 -1
  39. data/lib/bundler/man/bundle-list.1 +1 -1
  40. data/lib/bundler/man/bundle-lock.1 +1 -1
  41. data/lib/bundler/man/bundle-open.1 +1 -1
  42. data/lib/bundler/man/bundle-outdated.1 +1 -1
  43. data/lib/bundler/man/bundle-platform.1 +1 -1
  44. data/lib/bundler/man/bundle-pristine.1 +1 -1
  45. data/lib/bundler/man/bundle-remove.1 +1 -1
  46. data/lib/bundler/man/bundle-show.1 +1 -1
  47. data/lib/bundler/man/bundle-update.1 +1 -1
  48. data/lib/bundler/man/bundle-viz.1 +1 -1
  49. data/lib/bundler/man/bundle.1 +1 -1
  50. data/lib/bundler/man/gemfile.5 +1 -1
  51. data/lib/bundler/plugin.rb +3 -2
  52. data/lib/bundler/plugin/api/source.rb +7 -0
  53. data/lib/bundler/plugin/installer.rb +8 -10
  54. data/lib/bundler/plugin/source_list.rb +4 -0
  55. data/lib/bundler/resolver.rb +82 -65
  56. data/lib/bundler/resolver/spec_group.rb +53 -38
  57. data/lib/bundler/retry.rb +1 -1
  58. data/lib/bundler/rubygems_gem_installer.rb +47 -0
  59. data/lib/bundler/settings.rb +60 -10
  60. data/lib/bundler/shared_helpers.rb +2 -2
  61. data/lib/bundler/source.rb +6 -0
  62. data/lib/bundler/source/metadata.rb +0 -4
  63. data/lib/bundler/source/path.rb +3 -1
  64. data/lib/bundler/source/path/installer.rb +1 -1
  65. data/lib/bundler/source/rubygems.rb +22 -6
  66. data/lib/bundler/source_list.rb +29 -24
  67. data/lib/bundler/spec_set.rb +22 -8
  68. data/lib/bundler/stub_specification.rb +8 -0
  69. data/lib/bundler/templates/Gemfile +1 -1
  70. data/lib/bundler/templates/gems.rb +1 -1
  71. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  72. data/lib/bundler/templates/newgem/README.md.tt +5 -3
  73. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -4
  74. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -1
  75. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  76. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
  77. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -1
  78. data/lib/bundler/vendor/thor/lib/thor.rb +5 -6
  79. data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
  80. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
  81. data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
  82. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  83. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
  84. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
  85. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  86. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  87. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +1 -1
  88. data/lib/bundler/version.rb +1 -1
  89. metadata +4 -3
data/lib/bundler/dsl.rb CHANGED
@@ -24,6 +24,9 @@ module Bundler
24
24
  def initialize
25
25
  @source = nil
26
26
  @sources = SourceList.new
27
+
28
+ @global_rubygems_sources = []
29
+
27
30
  @git_sources = {}
28
31
  @dependencies = []
29
32
  @groups = []
@@ -45,6 +48,7 @@ module Bundler
45
48
  @gemfiles << expanded_gemfile_path
46
49
  contents ||= Bundler.read_file(@gemfile.to_s)
47
50
  instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
51
+ check_primary_source_safety
48
52
  rescue Exception => e # rubocop:disable Lint/RescueException
49
53
  message = "There was an error " \
50
54
  "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
@@ -164,8 +168,7 @@ module Bundler
164
168
  elsif block_given?
165
169
  with_source(@sources.add_rubygems_source("remotes" => source), &blk)
166
170
  else
167
- check_primary_source_safety(@sources)
168
- @sources.global_rubygems_source = source
171
+ @global_rubygems_sources << source
169
172
  end
170
173
  end
171
174
 
@@ -183,24 +186,14 @@ module Bundler
183
186
  end
184
187
 
185
188
  def path(path, options = {}, &blk)
186
- unless block_given?
187
- msg = "You can no longer specify a path source by itself. Instead, \n" \
188
- "either use the :path option on a gem, or specify the gems that \n" \
189
- "bundler should find in the path source by passing a block to \n" \
190
- "the path method, like: \n\n" \
191
- " path 'dir/containing/rails' do\n" \
192
- " gem 'rails'\n" \
193
- " end\n\n"
194
-
195
- raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource?
196
- SharedHelpers.major_deprecation(2, msg.strip)
197
- end
198
-
199
189
  source_options = normalize_hash(options).merge(
200
190
  "path" => Pathname.new(path),
201
191
  "root_path" => gemfile_root,
202
192
  "gemspec" => gemspecs.find {|g| g.name == options["name"] }
203
193
  )
194
+
195
+ source_options["global"] = true unless block_given?
196
+
204
197
  source = @sources.add_path_source(source_options)
205
198
  with_source(source, &blk)
206
199
  end
@@ -279,6 +272,11 @@ module Bundler
279
272
  raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile"
280
273
  end
281
274
 
275
+ def check_primary_source_safety
276
+ check_path_source_safety
277
+ check_rubygems_source_safety
278
+ end
279
+
282
280
  private
283
281
 
284
282
  def add_git_sources
@@ -440,25 +438,38 @@ repo_name ||= user_name
440
438
  end
441
439
  end
442
440
 
443
- def check_primary_source_safety(source_list)
444
- return if source_list.rubygems_primary_remotes.empty? && source_list.global_rubygems_source.nil?
441
+ def check_path_source_safety
442
+ return if @sources.global_path_source.nil?
443
+
444
+ msg = "You can no longer specify a path source by itself. Instead, \n" \
445
+ "either use the :path option on a gem, or specify the gems that \n" \
446
+ "bundler should find in the path source by passing a block to \n" \
447
+ "the path method, like: \n\n" \
448
+ " path 'dir/containing/rails' do\n" \
449
+ " gem 'rails'\n" \
450
+ " end\n\n"
451
+
452
+ SharedHelpers.major_deprecation(2, msg.strip)
453
+ end
454
+
455
+ def check_rubygems_source_safety
456
+ @sources.global_rubygems_source = @global_rubygems_sources.shift
457
+ return if @global_rubygems_sources.empty?
445
458
 
446
- if Bundler.feature_flag.disable_multisource?
459
+ @global_rubygems_sources.each do |source|
460
+ @sources.add_rubygems_remote(source)
461
+ end
462
+
463
+ if Bundler.feature_flag.bundler_3_mode?
447
464
  msg = "This Gemfile contains multiple primary sources. " \
448
465
  "Each source after the first must include a block to indicate which gems " \
449
466
  "should come from that source"
450
- unless Bundler.feature_flag.bundler_2_mode?
451
- msg += ". To downgrade this error to a warning, run " \
452
- "`bundle config unset disable_multisource`"
453
- end
454
467
  raise GemfileEvalError, msg
455
468
  else
456
469
  Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \
457
470
  "Using `source` more than once without a block is a security risk, and " \
458
471
  "may result in installing unexpected gems. To resolve this warning, use " \
459
- "a block to indicate which gems should come from the secondary source. " \
460
- "To upgrade this warning to an error, run `bundle config set --local " \
461
- "disable_multisource true`."
472
+ "a block to indicate which gems should come from the secondary source."
462
473
  end
463
474
  end
464
475
 
@@ -35,7 +35,6 @@ module Bundler
35
35
  settings_flag(:disable_multisource) { bundler_3_mode? }
36
36
  settings_flag(:forget_cli_options) { bundler_3_mode? }
37
37
  settings_flag(:global_gem_cache) { bundler_3_mode? }
38
- settings_flag(:only_update_to_newer_versions) { bundler_3_mode? }
39
38
  settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
40
39
  settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
41
40
  settings_flag(:print_only_version_number) { bundler_3_mode? }
@@ -47,7 +47,8 @@ module Bundler
47
47
  remote_uri = filter_uri(remote_uri)
48
48
  super "Authentication is required for #{remote_uri}.\n" \
49
49
  "Please supply credentials for this source. You can do this by running:\n" \
50
- " bundle config set --global #{remote_uri} username:password"
50
+ "`bundle config set --global #{remote_uri} username:password`\n" \
51
+ "or by storing the credentials in the `#{Settings.key_for(remote_uri)}` environment variable"
51
52
  end
52
53
  end
53
54
  # This error is raised if HTTP authentication is provided, but incorrect.
@@ -14,8 +14,10 @@ module Bundler
14
14
  def fetch(uri, headers = {}, counter = 0)
15
15
  raise HTTPError, "Too many redirects" if counter >= redirect_limit
16
16
 
17
+ filtered_uri = URICredentialsFilter.credential_filtered_uri(uri)
18
+
17
19
  response = request(uri, headers)
18
- Bundler.ui.debug("HTTP #{response.code} #{response.message} #{uri}")
20
+ Bundler.ui.debug("HTTP #{response.code} #{response.message} #{filtered_uri}")
19
21
 
20
22
  case response
21
23
  when Net::HTTPSuccess, Net::HTTPNotModified
@@ -40,7 +42,7 @@ module Bundler
40
42
  raise BadAuthenticationError, uri.host if uri.userinfo
41
43
  raise AuthenticationRequiredError, uri.host
42
44
  when Net::HTTPNotFound
43
- raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}"
45
+ raise FallbackError, "Net::HTTPNotFound: #{filtered_uri}"
44
46
  else
45
47
  raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}"
46
48
  end
@@ -49,7 +51,9 @@ module Bundler
49
51
  def request(uri, headers)
50
52
  validate_uri_scheme!(uri)
51
53
 
52
- Bundler.ui.debug "HTTP GET #{uri}"
54
+ filtered_uri = URICredentialsFilter.credential_filtered_uri(uri)
55
+
56
+ Bundler.ui.debug "HTTP GET #{filtered_uri}"
53
57
  req = Net::HTTP::Get.new uri.request_uri, headers
54
58
  if uri.user
55
59
  user = CGI.unescape(uri.user)
@@ -69,7 +73,7 @@ module Bundler
69
73
  raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
70
74
  "connection and try again."
71
75
  else
72
- raise HTTPError, "Network error while fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" \
76
+ raise HTTPError, "Network error while fetching #{filtered_uri}" \
73
77
  " (#{e})"
74
78
  end
75
79
  end
@@ -47,6 +47,11 @@ module Bundler
47
47
  built_gem_path = build_gem
48
48
  end
49
49
 
50
+ desc "Generate SHA512 checksum if #{name}-#{version}.gem into the checksums directory."
51
+ task "build:checksum" => "build" do
52
+ build_checksum(built_gem_path)
53
+ end
54
+
50
55
  desc "Build and install #{name}-#{version}.gem into system gems."
51
56
  task "install" => "build" do
52
57
  install_gem(built_gem_path)
@@ -100,6 +105,17 @@ module Bundler
100
105
  Bundler.ui.confirm "#{name} (#{version}) installed."
101
106
  end
102
107
 
108
+ def build_checksum(built_gem_path = nil)
109
+ built_gem_path ||= build_gem
110
+ SharedHelpers.filesystem_access(File.join(base, "checksums")) {|p| FileUtils.mkdir_p(p) }
111
+ file_name = "#{File.basename(built_gem_path)}.sha512"
112
+ require "digest/sha2"
113
+ checksum = Digest::SHA512.new.hexdigest(built_gem_path.to_s)
114
+ target = File.join(base, "checksums", file_name)
115
+ File.write(target, checksum)
116
+ Bundler.ui.confirm "#{name} #{version} checksum written to checksums/#{file_name}."
117
+ end
118
+
103
119
  protected
104
120
 
105
121
  def rubygem_push(path)
data/lib/bundler/index.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "set"
4
-
5
3
  module Bundler
6
4
  class Index
7
5
  include Enumerable
@@ -65,11 +63,14 @@ module Bundler
65
63
  def unsorted_search(query, base)
66
64
  results = local_search(query, base)
67
65
 
68
- seen = results.map(&:full_name).to_set unless @sources.empty?
66
+ seen = results.map(&:full_name).uniq unless @sources.empty?
69
67
 
70
68
  @sources.each do |source|
71
69
  source.unsorted_search(query, base).each do |spec|
72
- results << spec if seen.add?(spec.full_name)
70
+ next if seen.include?(spec.full_name)
71
+
72
+ seen << spec.full_name
73
+ results << spec
73
74
  end
74
75
  end
75
76
 
@@ -170,7 +171,7 @@ module Bundler
170
171
  def dependencies_eql?(spec, other_spec)
171
172
  deps = spec.dependencies.select {|d| d.type != :development }
172
173
  other_deps = other_spec.dependencies.select {|d| d.type != :development }
173
- Set.new(deps) == Set.new(other_deps)
174
+ deps.sort == other_deps.sort
174
175
  end
175
176
 
176
177
  def add_source(index)
@@ -128,7 +128,7 @@ module Bundler
128
128
  # evaluates a gemfile to remove the specified gem
129
129
  # from it.
130
130
  def remove_deps(gemfile_path)
131
- initial_gemfile = IO.readlines(gemfile_path)
131
+ initial_gemfile = File.readlines(gemfile_path)
132
132
 
133
133
  Bundler.ui.info "Removing gems from #{gemfile_path}"
134
134
 
@@ -181,7 +181,7 @@ module Bundler
181
181
  patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2\)/
182
182
  new_gemfile = []
183
183
  multiline_removal = false
184
- IO.readlines(gemfile_path).each do |line|
184
+ File.readlines(gemfile_path).each do |line|
185
185
  match_data = line.match(patterns)
186
186
  if match_data && is_not_within_comment?(line, match_data)
187
187
  multiline_removal = line.rstrip.end_with?(",")
@@ -50,8 +50,9 @@ def gemfile(install = false, options = {}, &gemfile)
50
50
  Bundler::Plugin.gemfile_install(&gemfile) if Bundler.feature_flag.plugins?
51
51
  builder = Bundler::Dsl.new
52
52
  builder.instance_eval(&gemfile)
53
+ builder.check_primary_source_safety
53
54
 
54
- Bundler.settings.temporary(:frozen => false) do
55
+ Bundler.settings.temporary(:deployment => false, :frozen => false) do
55
56
  definition = builder.to_definition(nil, true)
56
57
  def definition.lock(*); end
57
58
  definition.validate_runtime!
@@ -89,6 +89,8 @@ module Bundler
89
89
  end
90
90
  install(options)
91
91
 
92
+ Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
93
+
92
94
  lock unless Bundler.frozen_bundle?
93
95
  Standalone.new(options[:standalone], @definition).generate if options[:standalone]
94
96
  end
@@ -6,10 +6,11 @@ require_relative "gem_installer"
6
6
  module Bundler
7
7
  class ParallelInstaller
8
8
  class SpecInstallation
9
- attr_accessor :spec, :name, :post_install_message, :state, :error
9
+ attr_accessor :spec, :name, :full_name, :post_install_message, :state, :error
10
10
  def initialize(spec)
11
11
  @spec = spec
12
12
  @name = spec.name
13
+ @full_name = spec.full_name
13
14
  @state = :none
14
15
  @post_install_message = ""
15
16
  @error = nil
@@ -27,13 +28,8 @@ module Bundler
27
28
  state == :failed
28
29
  end
29
30
 
30
- def installation_attempted?
31
- installed? || failed?
32
- end
33
-
34
- # Only true when spec in neither installed nor already enqueued
35
31
  def ready_to_enqueue?
36
- !enqueued? && !installation_attempted?
32
+ state == :none
37
33
  end
38
34
 
39
35
  def has_post_install_message?
@@ -54,14 +50,11 @@ module Bundler
54
50
  # Represents only the non-development dependencies, the ones that are
55
51
  # itself and are in the total list.
56
52
  def dependencies
57
- @dependencies ||= begin
58
- all_dependencies.reject {|dep| ignorable_dependency? dep }
59
- end
53
+ @dependencies ||= all_dependencies.reject {|dep| ignorable_dependency? dep }
60
54
  end
61
55
 
62
56
  def missing_lockfile_dependencies(all_spec_names)
63
- deps = all_dependencies.reject {|dep| ignorable_dependency? dep }
64
- deps.reject {|dep| all_spec_names.include? dep.name }
57
+ dependencies.reject {|dep| all_spec_names.include? dep.name }
65
58
  end
66
59
 
67
60
  # Represents all dependencies
@@ -70,7 +63,7 @@ module Bundler
70
63
  end
71
64
 
72
65
  def to_s
73
- "#<#{self.class} #{@spec.full_name} (#{state})>"
66
+ "#<#{self.class} #{full_name} (#{state})>"
74
67
  end
75
68
  end
76
69
 
@@ -93,18 +86,48 @@ module Bundler
93
86
  def call
94
87
  check_for_corrupt_lockfile
95
88
 
89
+ if @rake
90
+ do_install(@rake, 0)
91
+ Gem::Specification.reset
92
+ end
93
+
96
94
  if @size > 1
97
95
  install_with_worker
98
96
  else
99
97
  install_serially
100
98
  end
101
99
 
100
+ check_for_unmet_dependencies
101
+
102
102
  handle_error if failed_specs.any?
103
103
  @specs
104
104
  ensure
105
105
  worker_pool && worker_pool.stop
106
106
  end
107
107
 
108
+ def check_for_unmet_dependencies
109
+ unmet_dependencies = @specs.map do |s|
110
+ [
111
+ s,
112
+ s.dependencies.reject {|dep| @specs.any? {|spec| dep.matches_spec?(spec.spec) } },
113
+ ]
114
+ end.reject {|a| a.last.empty? }
115
+ return if unmet_dependencies.empty?
116
+
117
+ warning = []
118
+ warning << "Your lockfile doesn't include a valid resolution."
119
+ warning << "You can fix this by regenerating your lockfile or trying to manually editing the bad locked gems to a version that satisfies all dependencies."
120
+ warning << "The unmet dependencies are:"
121
+
122
+ unmet_dependencies.each do |spec, unmet_spec_dependencies|
123
+ unmet_spec_dependencies.each do |unmet_spec_dependency|
124
+ warning << "* #{unmet_spec_dependency}, depended upon #{spec.full_name}, unsatisfied by #{@specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) }.full_name}"
125
+ end
126
+ end
127
+
128
+ Bundler.ui.warn(warning.join("\n"))
129
+ end
130
+
108
131
  def check_for_corrupt_lockfile
109
132
  missing_dependencies = @specs.map do |s|
110
133
  [
@@ -217,8 +240,6 @@ module Bundler
217
240
  # are installed.
218
241
  def enqueue_specs
219
242
  @specs.select(&:ready_to_enqueue?).each do |spec|
220
- next if @rake && !@rake.installed? && spec.name != @rake.name
221
-
222
243
  if spec.dependencies_installed? @specs
223
244
  spec.state = :enqueued
224
245
  worker_pool.enq spec
@@ -55,9 +55,10 @@ module Bundler
55
55
  kernel = (class << ::Kernel; self; end)
56
56
  [kernel, ::Kernel].each do |k|
57
57
  if k.private_method_defined?(:gem_original_require)
58
+ private_require = k.private_method_defined?(:require)
58
59
  k.send(:remove_method, :require)
59
60
  k.send(:define_method, :require, k.instance_method(:gem_original_require))
60
- k.send(:private, :require)
61
+ k.send(:private, :require) if private_require
61
62
  end
62
63
  end
63
64
  END
@@ -4,22 +4,6 @@ require_relative "match_platform"
4
4
 
5
5
  module Bundler
6
6
  class LazySpecification
7
- Identifier = Struct.new(:name, :version, :platform)
8
- class Identifier
9
- include Comparable
10
- def <=>(other)
11
- return unless other.is_a?(Identifier)
12
- [name, version, platform_string] <=> [other.name, other.version, other.platform_string]
13
- end
14
-
15
- protected
16
-
17
- def platform_string
18
- platform_string = platform.to_s
19
- platform_string == Index::RUBY ? Index::NULL : platform_string
20
- end
21
- end
22
-
23
7
  include MatchPlatform
24
8
 
25
9
  attr_reader :name, :version, :dependencies, :platform
@@ -89,7 +73,12 @@ module Bundler
89
73
  same_platform_candidates = candidates.select do |spec|
90
74
  MatchPlatform.platforms_match?(spec.platform, platform_object)
91
75
  end
92
- search = same_platform_candidates.last || candidates.last
76
+ installable_candidates = same_platform_candidates.select do |spec|
77
+ !spec.is_a?(EndpointSpecification) ||
78
+ (spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
79
+ spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version))
80
+ end
81
+ search = installable_candidates.last || same_platform_candidates.last
93
82
  search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
94
83
  search
95
84
  end
@@ -108,7 +97,7 @@ module Bundler
108
97
  end
109
98
 
110
99
  def identifier
111
- @__identifier ||= Identifier.new(name, version, platform)
100
+ @__identifier ||= [name, version, platform_string]
112
101
  end
113
102
 
114
103
  def git_version
@@ -116,6 +105,13 @@ module Bundler
116
105
  " #{source.revision[0..6]}"
117
106
  end
118
107
 
108
+ protected
109
+
110
+ def platform_string
111
+ platform_string = platform.to_s
112
+ platform_string == Index::RUBY ? Index::NULL : platform_string
113
+ end
114
+
119
115
  private
120
116
 
121
117
  def to_ary