bundler 2.4.22 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +63 -0
  3. data/bundler.gemspec +4 -2
  4. data/exe/bundle +1 -10
  5. data/lib/bundler/build_metadata.rb +3 -3
  6. data/lib/bundler/capistrano.rb +1 -1
  7. data/lib/bundler/checksum.rb +254 -0
  8. data/lib/bundler/ci_detector.rb +75 -0
  9. data/lib/bundler/cli/add.rb +3 -3
  10. data/lib/bundler/cli/binstubs.rb +4 -4
  11. data/lib/bundler/cli/cache.rb +1 -1
  12. data/lib/bundler/cli/check.rb +1 -1
  13. data/lib/bundler/cli/common.rb +9 -1
  14. data/lib/bundler/cli/config.rb +8 -7
  15. data/lib/bundler/cli/console.rb +3 -2
  16. data/lib/bundler/cli/doctor.rb +2 -2
  17. data/lib/bundler/cli/exec.rb +1 -1
  18. data/lib/bundler/cli/gem.rb +28 -23
  19. data/lib/bundler/cli/info.rb +2 -13
  20. data/lib/bundler/cli/install.rb +5 -4
  21. data/lib/bundler/cli/issue.rb +1 -1
  22. data/lib/bundler/cli/lock.rb +4 -4
  23. data/lib/bundler/cli/open.rb +1 -1
  24. data/lib/bundler/cli/outdated.rb +6 -6
  25. data/lib/bundler/cli/plugin.rb +7 -14
  26. data/lib/bundler/cli/pristine.rb +38 -30
  27. data/lib/bundler/cli/show.rb +2 -2
  28. data/lib/bundler/cli/update.rb +5 -5
  29. data/lib/bundler/cli.rb +215 -263
  30. data/lib/bundler/compact_index_client/cache.rb +29 -9
  31. data/lib/bundler/compact_index_client/cache_file.rb +153 -0
  32. data/lib/bundler/compact_index_client/gem_parser.rb +7 -3
  33. data/lib/bundler/compact_index_client/updater.rb +79 -81
  34. data/lib/bundler/compact_index_client.rb +14 -7
  35. data/lib/bundler/constants.rb +1 -1
  36. data/lib/bundler/current_ruby.rb +5 -21
  37. data/lib/bundler/definition.rb +42 -15
  38. data/lib/bundler/dependency.rb +16 -12
  39. data/lib/bundler/digest.rb +2 -2
  40. data/lib/bundler/dsl.rb +46 -30
  41. data/lib/bundler/endpoint_specification.rb +5 -1
  42. data/lib/bundler/env.rb +1 -3
  43. data/lib/bundler/errors.rb +43 -0
  44. data/lib/bundler/fetcher/base.rb +3 -1
  45. data/lib/bundler/fetcher/compact_index.rb +4 -4
  46. data/lib/bundler/fetcher/downloader.rb +13 -11
  47. data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  48. data/lib/bundler/fetcher/index.rb +1 -1
  49. data/lib/bundler/fetcher.rb +28 -25
  50. data/lib/bundler/friendly_errors.rb +5 -5
  51. data/lib/bundler/gem_helper.rb +1 -1
  52. data/lib/bundler/gem_helpers.rb +5 -2
  53. data/lib/bundler/graph.rb +9 -9
  54. data/lib/bundler/index.rb +1 -2
  55. data/lib/bundler/injector.rb +1 -1
  56. data/lib/bundler/inline.rb +3 -3
  57. data/lib/bundler/installer/gem_installer.rb +5 -5
  58. data/lib/bundler/installer/parallel_installer.rb +16 -8
  59. data/lib/bundler/installer/standalone.rb +2 -3
  60. data/lib/bundler/installer.rb +9 -9
  61. data/lib/bundler/lazy_specification.rb +24 -17
  62. data/lib/bundler/lockfile_generator.rb +9 -0
  63. data/lib/bundler/lockfile_parser.rb +81 -10
  64. data/lib/bundler/man/bundle-add.1 +3 -26
  65. data/lib/bundler/man/bundle-binstubs.1 +4 -16
  66. data/lib/bundler/man/bundle-cache.1 +3 -24
  67. data/lib/bundler/man/bundle-check.1 +3 -12
  68. data/lib/bundler/man/bundle-clean.1 +3 -10
  69. data/lib/bundler/man/bundle-config.1 +20 -211
  70. data/lib/bundler/man/bundle-config.1.ronn +6 -0
  71. data/lib/bundler/man/bundle-console.1 +4 -22
  72. data/lib/bundler/man/bundle-doctor.1 +4 -18
  73. data/lib/bundler/man/bundle-exec.1 +12 -73
  74. data/lib/bundler/man/bundle-gem.1 +13 -49
  75. data/lib/bundler/man/bundle-help.1 +3 -7
  76. data/lib/bundler/man/bundle-info.1 +3 -9
  77. data/lib/bundler/man/bundle-init.1 +3 -12
  78. data/lib/bundler/man/bundle-inject.1 +6 -19
  79. data/lib/bundler/man/bundle-install.1 +27 -125
  80. data/lib/bundler/man/bundle-install.1.ronn +1 -0
  81. data/lib/bundler/man/bundle-list.1 +4 -19
  82. data/lib/bundler/man/bundle-lock.1 +5 -29
  83. data/lib/bundler/man/bundle-open.1 +7 -27
  84. data/lib/bundler/man/bundle-outdated.1 +3 -55
  85. data/lib/bundler/man/bundle-outdated.1.ronn +1 -0
  86. data/lib/bundler/man/bundle-platform.1 +5 -27
  87. data/lib/bundler/man/bundle-plugin.1 +3 -29
  88. data/lib/bundler/man/bundle-pristine.1 +5 -16
  89. data/lib/bundler/man/bundle-remove.1 +4 -14
  90. data/lib/bundler/man/bundle-show.1 +3 -10
  91. data/lib/bundler/man/bundle-update.1 +18 -137
  92. data/lib/bundler/man/bundle-version.1 +3 -16
  93. data/lib/bundler/man/bundle-viz.1 +4 -16
  94. data/lib/bundler/man/bundle.1 +5 -44
  95. data/lib/bundler/man/gemfile.5 +24 -301
  96. data/lib/bundler/man/gemfile.5.ronn +4 -0
  97. data/lib/bundler/match_metadata.rb +4 -0
  98. data/lib/bundler/match_platform.rb +1 -1
  99. data/lib/bundler/plugin/api/source.rb +3 -2
  100. data/lib/bundler/plugin/installer.rb +1 -1
  101. data/lib/bundler/plugin.rb +3 -3
  102. data/lib/bundler/resolver/base.rb +1 -1
  103. data/lib/bundler/resolver/incompatibility.rb +1 -1
  104. data/lib/bundler/resolver/spec_group.rb +1 -4
  105. data/lib/bundler/resolver.rb +16 -16
  106. data/lib/bundler/ruby_dsl.rb +20 -12
  107. data/lib/bundler/ruby_version.rb +1 -1
  108. data/lib/bundler/rubygems_ext.rb +24 -50
  109. data/lib/bundler/rubygems_gem_installer.rb +6 -56
  110. data/lib/bundler/rubygems_integration.rb +25 -94
  111. data/lib/bundler/runtime.rb +2 -2
  112. data/lib/bundler/self_manager.rb +23 -7
  113. data/lib/bundler/settings.rb +27 -7
  114. data/lib/bundler/setup.rb +4 -1
  115. data/lib/bundler/shared_helpers.rb +35 -13
  116. data/lib/bundler/source/git/git_proxy.rb +15 -15
  117. data/lib/bundler/source/git.rb +4 -3
  118. data/lib/bundler/source/metadata.rb +15 -15
  119. data/lib/bundler/source/path.rb +7 -6
  120. data/lib/bundler/source/rubygems.rb +21 -14
  121. data/lib/bundler/source.rb +2 -0
  122. data/lib/bundler/spec_set.rb +38 -10
  123. data/lib/bundler/stub_specification.rb +1 -0
  124. data/lib/bundler/templates/Executable.bundler +1 -1
  125. data/lib/bundler/templates/newgem/README.md.tt +3 -3
  126. data/lib/bundler/templates/newgem/Rakefile.tt +2 -6
  127. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  128. data/lib/bundler/templates/newgem/standard.yml.tt +1 -1
  129. data/lib/bundler/ui/shell.rb +1 -1
  130. data/lib/bundler/vendor/connection_pool/.document +1 -0
  131. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  132. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +53 -6
  133. data/lib/bundler/vendor/fileutils/.document +1 -0
  134. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +8 -20
  135. data/lib/bundler/vendor/net-http-persistent/.document +1 -0
  136. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +3 -3
  137. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +2 -2
  138. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
  139. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +34 -34
  140. data/lib/bundler/vendor/pub_grub/.document +1 -0
  141. data/lib/bundler/vendor/thor/.document +1 -0
  142. data/lib/bundler/vendor/tsort/.document +1 -0
  143. data/lib/bundler/vendor/tsort/lib/tsort.rb +3 -0
  144. data/lib/bundler/vendor/uri/.document +1 -0
  145. data/lib/bundler/vendor/uri/lib/uri/common.rb +256 -132
  146. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1 -0
  147. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +95 -31
  148. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  149. data/lib/bundler/vendored_net_http.rb +8 -0
  150. data/lib/bundler/vendored_persistent.rb +0 -4
  151. data/lib/bundler/vendored_timeout.rb +8 -0
  152. data/lib/bundler/version.rb +1 -1
  153. data/lib/bundler/vlad.rb +1 -1
  154. data/lib/bundler/yaml_serializer.rb +3 -3
  155. data/lib/bundler.rb +41 -32
  156. metadata +18 -5
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "vendored_persistent"
4
+ require_relative "vendored_timeout"
4
5
  require "cgi"
5
6
  require "securerandom"
6
7
  require "zlib"
7
- require "rubygems/request"
8
8
 
9
9
  module Bundler
10
10
  # Handles all the fetching with the rubygems server
@@ -81,9 +81,9 @@ module Bundler
81
81
  :HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity,
82
82
  :HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze
83
83
  FAIL_ERRORS = begin
84
- fail_errors = [AuthenticationRequiredError, BadAuthenticationError, AuthenticationForbiddenError, FallbackError]
84
+ fail_errors = [AuthenticationRequiredError, BadAuthenticationError, AuthenticationForbiddenError, FallbackError, SecurityError]
85
85
  fail_errors << Gem::Requirement::BadRequirementError
86
- fail_errors.concat(NET_ERRORS.map {|e| Net.const_get(e) })
86
+ fail_errors.concat(NET_ERRORS.map {|e| Gem::Net.const_get(e) })
87
87
  end.freeze
88
88
 
89
89
  class << self
@@ -95,6 +95,7 @@ module Bundler
95
95
  self.max_retries = Bundler.settings[:retry] # How many retries for the API call
96
96
 
97
97
  def initialize(remote)
98
+ @cis = nil
98
99
  @remote = remote
99
100
 
100
101
  Socket.do_not_reverse_lookup = true
@@ -111,14 +112,16 @@ module Bundler
111
112
  spec_file_name = "#{spec.join "-"}.gemspec"
112
113
 
113
114
  uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
114
- if uri.scheme == "file"
115
- path = Bundler.rubygems.correct_for_windows_path(uri.path)
115
+ spec = if uri.scheme == "file"
116
+ path = Gem::Util.correct_for_windows_path(uri.path)
116
117
  Bundler.safe_load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
117
118
  elsif cached_spec_path = gemspec_cached_path(spec_file_name)
118
119
  Bundler.load_gemspec(cached_spec_path)
119
120
  else
120
121
  Bundler.safe_load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
121
122
  end
123
+ raise MarshalError, "is #{spec.inspect}" unless spec.is_a?(Gem::Specification)
124
+ spec
122
125
  rescue MarshalError
123
126
  raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
124
127
  "Your network or your gem server is probably having issues right now."
@@ -137,7 +140,9 @@ module Bundler
137
140
 
138
141
  fetch_specs(gem_names).each do |name, version, platform, dependencies, metadata|
139
142
  spec = if dependencies
140
- EndpointSpecification.new(name, version, platform, self, dependencies, metadata)
143
+ EndpointSpecification.new(name, version, platform, self, dependencies, metadata).tap do |es|
144
+ source.checksum_store.replace(es, es.checksum)
145
+ end
141
146
  else
142
147
  RemoteSpecification.new(name, version, platform, self)
143
148
  end
@@ -200,6 +205,16 @@ module Bundler
200
205
  fetchers.first.api_fetcher?
201
206
  end
202
207
 
208
+ def gem_remote_fetcher
209
+ @gem_remote_fetcher ||= begin
210
+ require_relative "fetcher/gem_remote_fetcher"
211
+ fetcher = GemRemoteFetcher.new Gem.configuration[:http_proxy]
212
+ fetcher.headers["User-Agent"] = user_agent
213
+ fetcher.headers["X-Gemfile-Source"] = @remote.original_uri.to_s if @remote.original_uri
214
+ fetcher
215
+ end
216
+ end
217
+
203
218
  private
204
219
 
205
220
  def available_fetchers
@@ -214,7 +229,7 @@ module Bundler
214
229
  end
215
230
 
216
231
  def fetchers
217
- @fetchers ||= available_fetchers.map {|f| f.new(downloader, @remote, uri) }.drop_while {|f| !f.available? }
232
+ @fetchers ||= available_fetchers.map {|f| f.new(downloader, @remote, uri, gem_remote_fetcher) }.drop_while {|f| !f.available? }
218
233
  end
219
234
 
220
235
  def fetch_specs(gem_names)
@@ -228,20 +243,7 @@ module Bundler
228
243
  end
229
244
 
230
245
  def cis
231
- env_cis = {
232
- "TRAVIS" => "travis",
233
- "CIRCLECI" => "circle",
234
- "SEMAPHORE" => "semaphore",
235
- "JENKINS_URL" => "jenkins",
236
- "BUILDBOX" => "buildbox",
237
- "GO_SERVER_URL" => "go",
238
- "SNAP_CI" => "snap",
239
- "GITLAB_CI" => "gitlab",
240
- "GITHUB_ACTIONS" => "github",
241
- "CI_NAME" => ENV["CI_NAME"],
242
- "CI" => "ci",
243
- }
244
- env_cis.find_all {|env, _| ENV[env] }.map {|_, ci| ci }
246
+ @cis ||= Bundler::CIDetector.ci_strings
245
247
  end
246
248
 
247
249
  def connection
@@ -251,7 +253,7 @@ module Bundler
251
253
  Bundler.settings[:ssl_client_cert]
252
254
  raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
253
255
 
254
- con = PersistentHTTP.new :name => "bundler", :proxy => :ENV
256
+ con = Gem::Net::HTTP::Persistent.new name: "bundler", proxy: :ENV
255
257
  if gem_proxy = Gem.configuration[:http_proxy]
256
258
  con.proxy = Bundler::URI.parse(gem_proxy) if gem_proxy != :no_proxy
257
259
  end
@@ -286,10 +288,10 @@ module Bundler
286
288
  end
287
289
 
288
290
  HTTP_ERRORS = [
289
- Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
291
+ Gem::Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
290
292
  Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
291
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
292
- PersistentHTTP::Error, Zlib::BufError, Errno::EHOSTUNREACH
293
+ Gem::Net::HTTPBadResponse, Gem::Net::HTTPHeaderSyntaxError, Gem::Net::ProtocolError,
294
+ Gem::Net::HTTP::Persistent::Error, Zlib::BufError, Errno::EHOSTUNREACH
293
295
  ].freeze
294
296
 
295
297
  def bundler_cert_store
@@ -305,6 +307,7 @@ module Bundler
305
307
  end
306
308
  else
307
309
  store.set_default_paths
310
+ require "rubygems/request"
308
311
  Gem::Request.get_cert_files.each {|c| store.add_file c }
309
312
  end
310
313
  store
@@ -32,7 +32,7 @@ module Bundler
32
32
  if Bundler.ui.debug?
33
33
  Bundler.ui.trace error
34
34
  else
35
- Bundler.ui.error error.message, :wrap => true
35
+ Bundler.ui.error error.message, wrap: true
36
36
  end
37
37
  when Thor::Error
38
38
  Bundler.ui.error error.message
@@ -40,7 +40,7 @@ module Bundler
40
40
  Bundler.ui.error "\nQuitting..."
41
41
  Bundler.ui.trace error
42
42
  when Gem::InvalidSpecificationException
43
- Bundler.ui.error error.message, :wrap => true
43
+ Bundler.ui.error error.message, wrap: true
44
44
  when SystemExit
45
45
  when *[defined?(Java::JavaLang::OutOfMemoryError) && Java::JavaLang::OutOfMemoryError].compact
46
46
  Bundler.ui.error "\nYour JVM has run out of memory, and Bundler cannot continue. " \
@@ -61,7 +61,7 @@ module Bundler
61
61
  end
62
62
 
63
63
  def request_issue_report_for(e)
64
- Bundler.ui.error <<-EOS.gsub(/^ {8}/, ""), nil, nil
64
+ Bundler.ui.error <<~EOS, nil, nil
65
65
  --- ERROR REPORT TEMPLATE -------------------------------------------------------
66
66
 
67
67
  ```
@@ -75,7 +75,7 @@ module Bundler
75
75
 
76
76
  Bundler.ui.error "Unfortunately, an unexpected error occurred, and Bundler cannot continue."
77
77
 
78
- Bundler.ui.error <<-EOS.gsub(/^ {8}/, ""), nil, :yellow
78
+ Bundler.ui.error <<~EOS, nil, :yellow
79
79
 
80
80
  First, try this link to see if there are any existing issue reports for this error:
81
81
  #{issues_url(e)}
@@ -93,7 +93,7 @@ module Bundler
93
93
  end
94
94
 
95
95
  def serialized_exception_for(e)
96
- <<-EOS.gsub(/^ {8}/, "")
96
+ <<~EOS
97
97
  #{e.class}: #{e.message}
98
98
  #{e.backtrace&.join("\n ")&.chomp}
99
99
  EOS
@@ -215,7 +215,7 @@ module Bundler
215
215
  def sh_with_status(cmd, &block)
216
216
  Bundler.ui.debug(cmd)
217
217
  SharedHelpers.chdir(base) do
218
- outbuf = IO.popen(cmd, :err => [:child, :out], &:read)
218
+ outbuf = IO.popen(cmd, err: [:child, :out], &:read)
219
219
  status = $?
220
220
  block&.call(outbuf) if status.success?
221
221
  [outbuf, status]
@@ -34,6 +34,11 @@ module Bundler
34
34
  end
35
35
  module_function :local_platform
36
36
 
37
+ def generic_local_platform_is_ruby?
38
+ generic_local_platform == Gem::Platform::RUBY
39
+ end
40
+ module_function :generic_local_platform_is_ruby?
41
+
37
42
  def platform_specificity_match(spec_platform, user_platform)
38
43
  spec_platform = Gem::Platform.new(spec_platform)
39
44
 
@@ -114,8 +119,6 @@ module Bundler
114
119
 
115
120
  def same_deps(spec, exemplary_spec)
116
121
  same_runtime_deps = spec.dependencies.sort == exemplary_spec.dependencies.sort
117
- return same_runtime_deps unless spec.is_a?(Gem::Specification) && exemplary_spec.is_a?(Gem::Specification)
118
-
119
122
  same_metadata_deps = spec.required_ruby_version == exemplary_spec.required_ruby_version && spec.required_rubygems_version == exemplary_spec.required_rubygems_version
120
123
  same_runtime_deps && same_metadata_deps
121
124
  end
data/lib/bundler/graph.rb CHANGED
@@ -84,7 +84,7 @@ module Bundler
84
84
  else
85
85
  raise ArgumentError, "2nd argument is invalid"
86
86
  end
87
- label.nil? ? {} : { :label => label }
87
+ label.nil? ? {} : { label: label }
88
88
  end
89
89
 
90
90
  def spec_for_dependency(dependency)
@@ -103,7 +103,7 @@ module Bundler
103
103
  end
104
104
 
105
105
  def g
106
- @g ||= ::GraphViz.digraph(@graph_name, :concentrate => true, :normalize => true, :nodesep => 0.55) do |g|
106
+ @g ||= ::GraphViz.digraph(@graph_name, concentrate: true, normalize: true, nodesep: 0.55) do |g|
107
107
  g.edge[:weight] = 2
108
108
  g.edge[:fontname] = g.node[:fontname] = "Arial, Helvetica, SansSerif"
109
109
  g.edge[:fontsize] = 12
@@ -114,10 +114,10 @@ module Bundler
114
114
  @groups.each do |group|
115
115
  g.add_nodes(
116
116
  group, {
117
- :style => "filled",
118
- :fillcolor => "#B9B9D5",
119
- :shape => "box3d",
120
- :fontsize => 16,
117
+ style: "filled",
118
+ fillcolor: "#B9B9D5",
119
+ shape: "box3d",
120
+ fontsize: 16,
121
121
  }.merge(@node_options[group])
122
122
  )
123
123
  end
@@ -125,8 +125,8 @@ module Bundler
125
125
  @relations.each do |parent, children|
126
126
  children.each do |child|
127
127
  if @groups.include?(parent)
128
- g.add_nodes(child, { :style => "filled", :fillcolor => "#B9B9D5" }.merge(@node_options[child]))
129
- g.add_edges(parent, child, { :constraint => false }.merge(@edge_options["#{parent}_#{child}"]))
128
+ g.add_nodes(child, { style: "filled", fillcolor: "#B9B9D5" }.merge(@node_options[child]))
129
+ g.add_edges(parent, child, { constraint: false }.merge(@edge_options["#{parent}_#{child}"]))
130
130
  else
131
131
  g.add_nodes(child, @node_options[child])
132
132
  g.add_edges(parent, child, @edge_options["#{parent}_#{child}"])
@@ -135,7 +135,7 @@ module Bundler
135
135
  end
136
136
 
137
137
  if @output_format.to_s == "debug"
138
- $stdout.puts g.output :none => String
138
+ $stdout.puts g.output none: String
139
139
  Bundler.ui.info "debugging bundle viz..."
140
140
  else
141
141
  begin
data/lib/bundler/index.rb CHANGED
@@ -145,8 +145,7 @@ module Bundler
145
145
  end
146
146
 
147
147
  # Whether all the specs in self are in other
148
- # TODO: rename to #include?
149
- def ==(other)
148
+ def subset?(other)
150
149
  all? do |spec|
151
150
  other_spec = other[spec].first
152
151
  other_spec && dependencies_eql?(spec, other_spec) && spec.source == other_spec.source
@@ -29,7 +29,7 @@ module Bundler
29
29
  end
30
30
 
31
31
  # temporarily unfreeze
32
- Bundler.settings.temporary(:deployment => false, :frozen => false) do
32
+ Bundler.settings.temporary(deployment: false, frozen: false) do
33
33
  # evaluate the Gemfile we have now
34
34
  builder = Dsl.new
35
35
  builder.eval_gemfile(gemfile_path)
@@ -48,14 +48,14 @@ def gemfile(install = false, options = {}, &gemfile)
48
48
  builder.instance_eval(&gemfile)
49
49
  builder.check_primary_source_safety
50
50
 
51
- Bundler.settings.temporary(:deployment => false, :frozen => false) do
51
+ Bundler.settings.temporary(deployment: false, frozen: false) do
52
52
  definition = builder.to_definition(nil, true)
53
53
  def definition.lock(*); end
54
54
  definition.validate_runtime!
55
55
 
56
56
  if install || definition.missing_specs?
57
- Bundler.settings.temporary(:inline => true, :no_install => false) do
58
- installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
57
+ Bundler.settings.temporary(inline: true, no_install: false) do
58
+ installer = Bundler::Installer.install(Bundler.root, definition, system: true)
59
59
  installer.post_install_messages.each do |name, message|
60
60
  Bundler.ui.info "Post-install message from #{name}:\n#{message}"
61
61
  end
@@ -53,10 +53,10 @@ module Bundler
53
53
  def install
54
54
  spec.source.install(
55
55
  spec,
56
- :force => force,
57
- :ensure_builtin_gems_cached => standalone,
58
- :build_args => Array(spec_settings),
59
- :previous_spec => previous_spec,
56
+ force: force,
57
+ ensure_builtin_gems_cached: standalone,
58
+ build_args: Array(spec_settings),
59
+ previous_spec: previous_spec,
60
60
  )
61
61
  end
62
62
 
@@ -77,7 +77,7 @@ module Bundler
77
77
  if Bundler.settings[:bin] && standalone
78
78
  installer.generate_standalone_bundler_executable_stubs(spec)
79
79
  elsif Bundler.settings[:bin]
80
- installer.generate_bundler_executable_stubs(spec, :force => true)
80
+ installer.generate_bundler_executable_stubs(spec, force: true)
81
81
  end
82
82
  end
83
83
  end
@@ -42,8 +42,7 @@ module Bundler
42
42
 
43
43
  # Checks installed dependencies against spec's dependencies to make
44
44
  # sure needed dependencies have been installed.
45
- def dependencies_installed?(all_specs)
46
- installed_specs = all_specs.select(&:installed?).map(&:name)
45
+ def dependencies_installed?(installed_specs)
47
46
  dependencies.all? {|d| installed_specs.include? d.name }
48
47
  end
49
48
 
@@ -63,20 +62,23 @@ module Bundler
63
62
  end
64
63
  end
65
64
 
66
- def self.call(*args)
67
- new(*args).call
65
+ def self.call(*args, **kwargs)
66
+ new(*args, **kwargs).call
68
67
  end
69
68
 
70
69
  attr_reader :size
71
70
 
72
- def initialize(installer, all_specs, size, standalone, force)
71
+ def initialize(installer, all_specs, size, standalone, force, skip: nil)
73
72
  @installer = installer
74
73
  @size = size
75
74
  @standalone = standalone
76
75
  @force = force
77
76
  @specs = all_specs.map {|s| SpecInstallation.new(s) }
77
+ @specs.each do |spec_install|
78
+ spec_install.state = :installed if skip.include?(spec_install.name)
79
+ end if skip
78
80
  @spec_set = all_specs
79
- @rake = @specs.find {|s| s.name == "rake" }
81
+ @rake = @specs.find {|s| s.name == "rake" unless s.installed? }
80
82
  end
81
83
 
82
84
  def call
@@ -183,8 +185,14 @@ module Bundler
183
185
  # previously installed specifications. We continue until all specs
184
186
  # are installed.
185
187
  def enqueue_specs
186
- @specs.select(&:ready_to_enqueue?).each do |spec|
187
- if spec.dependencies_installed? @specs
188
+ installed_specs = {}
189
+ @specs.each do |spec|
190
+ next unless spec.installed?
191
+ installed_specs[spec.name] = true
192
+ end
193
+
194
+ @specs.each do |spec|
195
+ if spec.ready_to_enqueue? && spec.dependencies_installed?(installed_specs)
188
196
  spec.state = :enqueued
189
197
  worker_pool.enq spec
190
198
  end
@@ -56,7 +56,7 @@ module Bundler
56
56
  if spec.source.instance_of?(Source::Path) && spec.source.path.absolute?
57
57
  full_path
58
58
  else
59
- SharedHelpers.relative_path_to(full_path, :from => Bundler.root.join(bundler_path))
59
+ SharedHelpers.relative_path_to(full_path, from: Bundler.root.join(bundler_path))
60
60
  end
61
61
  rescue TypeError
62
62
  error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
@@ -101,8 +101,7 @@ module Bundler
101
101
  if Gem.respond_to?(:discover_gems_on_require=)
102
102
  Gem.discover_gems_on_require = false
103
103
  else
104
- kernel = (class << ::Kernel; self; end)
105
- [kernel, ::Kernel].each do |k|
104
+ [::Kernel.singleton_class, ::Kernel].each do |k|
106
105
  if k.private_method_defined?(:gem_original_require)
107
106
  private_require = k.private_method_defined?(:require)
108
107
  k.send(:remove_method, :require)
@@ -136,12 +136,12 @@ module Bundler
136
136
 
137
137
  mode = Gem.win_platform? ? "wb:UTF-8" : "w"
138
138
  require "erb"
139
- content = ERB.new(template, :trim_mode => "-").result(binding)
139
+ content = ERB.new(template, trim_mode: "-").result(binding)
140
140
 
141
- File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask)
141
+ File.write(binstub_path, content, mode: mode, perm: 0o777 & ~File.umask)
142
142
  if Gem.win_platform? || options[:all_platforms]
143
143
  prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
144
- File.write("#{binstub_path}.cmd", prefix + content, :mode => mode)
144
+ File.write("#{binstub_path}.cmd", prefix + content, mode: mode)
145
145
  end
146
146
  end
147
147
 
@@ -179,12 +179,12 @@ module Bundler
179
179
 
180
180
  mode = Gem.win_platform? ? "wb:UTF-8" : "w"
181
181
  require "erb"
182
- content = ERB.new(template, :trim_mode => "-").result(binding)
182
+ content = ERB.new(template, trim_mode: "-").result(binding)
183
183
 
184
- File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755)
184
+ File.write("#{bin_path}/#{executable}", content, mode: mode, perm: 0o755)
185
185
  if Gem.win_platform? || options[:all_platforms]
186
186
  prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
187
- File.write("#{bin_path}/#{executable}.cmd", prefix + content, :mode => mode)
187
+ File.write("#{bin_path}/#{executable}.cmd", prefix + content, mode: mode)
188
188
  end
189
189
  end
190
190
  end
@@ -214,7 +214,7 @@ module Bundler
214
214
  end
215
215
 
216
216
  def load_plugins
217
- Bundler.rubygems.load_plugins
217
+ Gem.load_plugins
218
218
 
219
219
  requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
220
220
  path_plugin_files = requested_path_gems.map do |spec|
@@ -223,8 +223,8 @@ module Bundler
223
223
  error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
224
224
  raise Gem::InvalidSpecificationException, error_message
225
225
  end.flatten
226
- Bundler.rubygems.load_plugin_files(path_plugin_files)
227
- Bundler.rubygems.load_env_plugins
226
+ Gem.load_plugin_files(path_plugin_files)
227
+ Gem.load_env_plugins
228
228
  end
229
229
 
230
230
  def ensure_specs_are_compatible!
@@ -7,13 +7,23 @@ module Bundler
7
7
  include MatchPlatform
8
8
  include ForcePlatform
9
9
 
10
- attr_reader :name, :version, :dependencies, :platform
11
- attr_accessor :source, :remote, :force_ruby_platform
10
+ attr_reader :name, :version, :platform
11
+ attr_accessor :source, :remote, :force_ruby_platform, :dependencies, :required_ruby_version, :required_rubygems_version
12
+
13
+ def self.from_spec(s)
14
+ lazy_spec = new(s.name, s.version, s.platform, s.source)
15
+ lazy_spec.dependencies = s.dependencies
16
+ lazy_spec.required_ruby_version = s.required_ruby_version
17
+ lazy_spec.required_rubygems_version = s.required_rubygems_version
18
+ lazy_spec
19
+ end
12
20
 
13
21
  def initialize(name, version, platform, source = nil)
14
22
  @name = name
15
23
  @version = version
16
24
  @dependencies = []
25
+ @required_ruby_version = Gem::Requirement.default
26
+ @required_rubygems_version = Gem::Requirement.default
17
27
  @platform = platform || Gem::Platform::RUBY
18
28
  @source = source
19
29
  @force_ruby_platform = default_force_ruby_platform
@@ -27,6 +37,14 @@ module Bundler
27
37
  end
28
38
  end
29
39
 
40
+ def lock_name
41
+ @lock_name ||= name_tuple.lock_name
42
+ end
43
+
44
+ def name_tuple
45
+ Gem::NameTuple.new(@name, @version, @platform)
46
+ end
47
+
30
48
  def ==(other)
31
49
  full_name == other.full_name
32
50
  end
@@ -61,12 +79,7 @@ module Bundler
61
79
 
62
80
  def to_lock
63
81
  out = String.new
64
-
65
- if platform == Gem::Platform::RUBY
66
- out << " #{name} (#{version})\n"
67
- else
68
- out << " #{name} (#{version}-#{platform})\n"
69
- end
82
+ out << " #{lock_name}\n"
70
83
 
71
84
  dependencies.sort_by(&:to_s).uniq.each do |dep|
72
85
  next if dep.type == :development
@@ -89,7 +102,7 @@ module Bundler
89
102
 
90
103
  installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
91
104
 
92
- specification = __materialize__(installable_candidates, :fallback_to_non_installable => false)
105
+ specification = __materialize__(installable_candidates, fallback_to_non_installable: false)
93
106
  return specification unless specification.nil?
94
107
 
95
108
  if target_platform != platform
@@ -109,9 +122,7 @@ module Bundler
109
122
  # bad gem.
110
123
  def __materialize__(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
111
124
  search = candidates.reverse.find do |spec|
112
- spec.is_a?(StubSpecification) ||
113
- (spec.matches_current_ruby? &&
114
- spec.matches_current_rubygems?)
125
+ spec.is_a?(StubSpecification) || spec.matches_current_metadata?
115
126
  end
116
127
  if search.nil? && fallback_to_non_installable
117
128
  search = candidates.last
@@ -122,11 +133,7 @@ module Bundler
122
133
  end
123
134
 
124
135
  def to_s
125
- @to_s ||= if platform == Gem::Platform::RUBY
126
- "#{name} (#{version})"
127
- else
128
- "#{name} (#{version}-#{platform})"
129
- end
136
+ lock_name
130
137
  end
131
138
 
132
139
  def git_version
@@ -19,6 +19,7 @@ module Bundler
19
19
  add_sources
20
20
  add_platforms
21
21
  add_dependencies
22
+ add_checksums
22
23
  add_locked_ruby_version
23
24
  add_bundled_with
24
25
 
@@ -65,6 +66,14 @@ module Bundler
65
66
  end
66
67
  end
67
68
 
69
+ def add_checksums
70
+ return unless definition.locked_checksums
71
+ checksums = definition.resolve.map do |spec|
72
+ spec.source.checksum_store.to_lock(spec)
73
+ end
74
+ add_section("CHECKSUMS", checksums)
75
+ end
76
+
68
77
  def add_locked_ruby_version
69
78
  return unless locked_ruby_version = definition.locked_ruby_version
70
79
  add_section("RUBY VERSION", locked_ruby_version.to_s)