bundler 2.2.26 → 2.3.26

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 (197) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +501 -1
  3. data/README.md +1 -1
  4. data/bundler.gemspec +6 -8
  5. data/exe/bundle +7 -8
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/cli/check.rb +1 -1
  10. data/lib/bundler/cli/common.rb +3 -2
  11. data/lib/bundler/cli/config.rb +10 -1
  12. data/lib/bundler/cli/doctor.rb +12 -3
  13. data/lib/bundler/cli/gem.rb +98 -9
  14. data/lib/bundler/cli/info.rb +27 -6
  15. data/lib/bundler/cli/init.rb +5 -1
  16. data/lib/bundler/cli/install.rb +13 -30
  17. data/lib/bundler/cli/issue.rb +4 -3
  18. data/lib/bundler/cli/outdated.rb +12 -3
  19. data/lib/bundler/cli/platform.rb +2 -2
  20. data/lib/bundler/cli/remove.rb +1 -2
  21. data/lib/bundler/cli/show.rb +1 -1
  22. data/lib/bundler/cli/update.rb +8 -4
  23. data/lib/bundler/cli.rb +23 -19
  24. data/lib/bundler/compact_index_client/cache.rb +0 -9
  25. data/lib/bundler/compact_index_client/updater.rb +16 -8
  26. data/lib/bundler/compact_index_client.rb +2 -8
  27. data/lib/bundler/current_ruby.rb +16 -6
  28. data/lib/bundler/definition.rb +204 -217
  29. data/lib/bundler/dependency.rb +23 -71
  30. data/lib/bundler/digest.rb +71 -0
  31. data/lib/bundler/dsl.rb +28 -45
  32. data/lib/bundler/endpoint_specification.rb +19 -13
  33. data/lib/bundler/env.rb +1 -1
  34. data/lib/bundler/environment_preserver.rb +4 -1
  35. data/lib/bundler/errors.rb +28 -2
  36. data/lib/bundler/feature_flag.rb +0 -1
  37. data/lib/bundler/fetcher/base.rb +6 -8
  38. data/lib/bundler/fetcher/compact_index.rb +9 -14
  39. data/lib/bundler/fetcher/index.rb +0 -26
  40. data/lib/bundler/fetcher.rb +20 -22
  41. data/lib/bundler/friendly_errors.rb +26 -34
  42. data/lib/bundler/gem_helper.rb +7 -18
  43. data/lib/bundler/gem_helpers.rb +9 -2
  44. data/lib/bundler/gem_version_promoter.rb +14 -25
  45. data/lib/bundler/index.rb +10 -40
  46. data/lib/bundler/injector.rb +16 -2
  47. data/lib/bundler/inline.rb +2 -12
  48. data/lib/bundler/installer/gem_installer.rb +13 -5
  49. data/lib/bundler/installer/standalone.rb +30 -3
  50. data/lib/bundler/installer.rb +18 -29
  51. data/lib/bundler/lazy_specification.rb +52 -35
  52. data/lib/bundler/lockfile_generator.rb +2 -2
  53. data/lib/bundler/lockfile_parser.rb +12 -10
  54. data/lib/bundler/man/bundle-add.1 +21 -5
  55. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  56. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  57. data/lib/bundler/man/bundle-cache.1 +7 -1
  58. data/lib/bundler/man/bundle-cache.1.ronn +7 -0
  59. data/lib/bundler/man/bundle-check.1 +1 -1
  60. data/lib/bundler/man/bundle-clean.1 +2 -2
  61. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  62. data/lib/bundler/man/bundle-config.1 +33 -14
  63. data/lib/bundler/man/bundle-config.1.ronn +30 -18
  64. data/lib/bundler/man/bundle-console.1 +53 -0
  65. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  66. data/lib/bundler/man/bundle-doctor.1 +1 -1
  67. data/lib/bundler/man/bundle-exec.1 +2 -2
  68. data/lib/bundler/man/bundle-exec.1.ronn +1 -1
  69. data/lib/bundler/man/bundle-gem.1 +14 -1
  70. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  71. data/lib/bundler/man/bundle-help.1 +13 -0
  72. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  73. data/lib/bundler/man/bundle-info.1 +1 -1
  74. data/lib/bundler/man/bundle-init.1 +1 -1
  75. data/lib/bundler/man/bundle-inject.1 +5 -2
  76. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  77. data/lib/bundler/man/bundle-install.1 +6 -2
  78. data/lib/bundler/man/bundle-install.1.ronn +8 -2
  79. data/lib/bundler/man/bundle-list.1 +1 -1
  80. data/lib/bundler/man/bundle-lock.1 +1 -1
  81. data/lib/bundler/man/bundle-open.1 +1 -1
  82. data/lib/bundler/man/bundle-outdated.1 +3 -10
  83. data/lib/bundler/man/bundle-outdated.1.ronn +1 -10
  84. data/lib/bundler/man/bundle-platform.1 +16 -6
  85. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  86. data/lib/bundler/man/bundle-plugin.1 +81 -0
  87. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  88. data/lib/bundler/man/bundle-pristine.1 +1 -1
  89. data/lib/bundler/man/bundle-remove.1 +1 -1
  90. data/lib/bundler/man/bundle-show.1 +1 -1
  91. data/lib/bundler/man/bundle-update.1 +2 -2
  92. data/lib/bundler/man/bundle-update.1.ronn +2 -1
  93. data/lib/bundler/man/bundle-version.1 +35 -0
  94. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  95. data/lib/bundler/man/bundle-viz.1 +4 -1
  96. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  97. data/lib/bundler/man/bundle.1 +15 -10
  98. data/lib/bundler/man/bundle.1.ronn +12 -7
  99. data/lib/bundler/man/gemfile.5 +117 -80
  100. data/lib/bundler/man/gemfile.5.ronn +105 -84
  101. data/lib/bundler/man/index.txt +4 -0
  102. data/lib/bundler/match_metadata.rb +13 -0
  103. data/lib/bundler/match_platform.rb +0 -1
  104. data/lib/bundler/match_remote_metadata.rb +29 -0
  105. data/lib/bundler/plugin/api/source.rb +4 -9
  106. data/lib/bundler/plugin/installer/git.rb +0 -4
  107. data/lib/bundler/plugin/installer/rubygems.rb +0 -4
  108. data/lib/bundler/plugin/installer.rb +3 -1
  109. data/lib/bundler/plugin.rb +25 -6
  110. data/lib/bundler/process_lock.rb +1 -1
  111. data/lib/bundler/remote_specification.rb +10 -4
  112. data/lib/bundler/resolver/base.rb +50 -0
  113. data/lib/bundler/resolver/spec_group.rb +31 -49
  114. data/lib/bundler/resolver.rb +183 -192
  115. data/lib/bundler/ruby_dsl.rb +1 -1
  116. data/lib/bundler/ruby_version.rb +5 -18
  117. data/lib/bundler/rubygems_ext.rb +138 -20
  118. data/lib/bundler/rubygems_gem_installer.rb +42 -16
  119. data/lib/bundler/rubygems_integration.rb +42 -90
  120. data/lib/bundler/runtime.rb +2 -3
  121. data/lib/bundler/self_manager.rb +168 -0
  122. data/lib/bundler/settings.rb +13 -4
  123. data/lib/bundler/shared_helpers.rb +15 -24
  124. data/lib/bundler/source/git/git_proxy.rb +7 -4
  125. data/lib/bundler/source/git.rb +29 -13
  126. data/lib/bundler/source/metadata.rb +3 -3
  127. data/lib/bundler/source/path.rb +1 -1
  128. data/lib/bundler/source/rubygems.rb +148 -161
  129. data/lib/bundler/source/rubygems_aggregate.rb +1 -1
  130. data/lib/bundler/source.rb +6 -5
  131. data/lib/bundler/source_list.rb +15 -29
  132. data/lib/bundler/source_map.rb +15 -2
  133. data/lib/bundler/spec_set.rb +52 -32
  134. data/lib/bundler/stub_specification.rb +5 -3
  135. data/lib/bundler/templates/Executable +2 -4
  136. data/lib/bundler/templates/Executable.bundler +2 -2
  137. data/lib/bundler/templates/Executable.standalone +2 -4
  138. data/lib/bundler/templates/Gemfile +0 -2
  139. data/lib/bundler/templates/gems.rb +0 -3
  140. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  141. data/lib/bundler/templates/newgem/README.md.tt +3 -9
  142. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  143. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +5 -4
  144. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +5 -4
  145. data/lib/bundler/templates/newgem/newgem.gemspec.tt +16 -16
  146. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  147. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  148. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  149. data/lib/bundler/ui/shell.rb +1 -1
  150. data/lib/bundler/vendor/.document +1 -0
  151. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  152. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  153. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  154. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  155. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  156. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  157. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  158. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -3
  159. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +32 -26
  160. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  161. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  162. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  163. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  164. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  165. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  166. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  167. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  168. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  169. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  170. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  171. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  172. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  173. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  174. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  175. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  176. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  177. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  178. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  179. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  180. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  181. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  182. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  183. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  184. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  185. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  186. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  187. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  188. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  189. data/lib/bundler/vendored_tsort.rb +4 -0
  190. data/lib/bundler/version.rb +1 -1
  191. data/lib/bundler/worker.rb +2 -2
  192. data/lib/bundler.rb +40 -29
  193. metadata +37 -12
  194. data/lib/bundler/dep_proxy.rb +0 -55
  195. data/lib/bundler/gemdeps.rb +0 -29
  196. data/lib/bundler/psyched_yaml.rb +0 -22
  197. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -26,6 +26,13 @@ module Bundler
26
26
  Array(options["remotes"]).reverse_each {|r| add_remote(r) }
27
27
  end
28
28
 
29
+ def local_only!
30
+ @specs = nil
31
+ @allow_local = true
32
+ @allow_cached = false
33
+ @allow_remote = false
34
+ end
35
+
29
36
  def local!
30
37
  return if @allow_local
31
38
 
@@ -91,26 +98,30 @@ module Bundler
91
98
  out << " specs:\n"
92
99
  end
93
100
 
94
- def to_err
101
+ def to_s
95
102
  if remotes.empty?
96
103
  "locally installed gems"
97
- elsif @allow_remote
104
+ elsif @allow_remote && @allow_cached && @allow_local
105
+ "rubygems repository #{remote_names}, cached gems or installed locally"
106
+ elsif @allow_remote && @allow_local
98
107
  "rubygems repository #{remote_names} or installed locally"
99
- elsif @allow_cached
100
- "cached gems from rubygems repository #{remote_names} or installed locally"
108
+ elsif @allow_remote
109
+ "rubygems repository #{remote_names}"
110
+ elsif @allow_cached && @allow_local
111
+ "cached gems or installed locally"
101
112
  else
102
113
  "locally installed gems"
103
114
  end
104
115
  end
105
116
 
106
- def to_s
117
+ def identifier
107
118
  if remotes.empty?
108
119
  "locally installed gems"
109
120
  else
110
- "rubygems repository #{remote_names} or installed locally"
121
+ "rubygems repository #{remote_names}"
111
122
  end
112
123
  end
113
- alias_method :name, :to_s
124
+ alias_method :name, :identifier
114
125
 
115
126
  def specs
116
127
  @specs ||= begin
@@ -124,101 +135,104 @@ module Bundler
124
135
  end
125
136
  end
126
137
 
127
- def install(spec, opts = {})
128
- force = opts[:force]
129
- ensure_builtin_gems_cached = opts[:ensure_builtin_gems_cached]
138
+ def install(spec, options = {})
139
+ force = options[:force]
140
+ ensure_builtin_gems_cached = options[:ensure_builtin_gems_cached]
130
141
 
131
- if ensure_builtin_gems_cached && builtin_gem?(spec)
132
- if !cached_path(spec)
133
- cached_built_in_gem(spec) unless spec.remote
134
- force = true
135
- else
136
- spec.loaded_from = loaded_from(spec)
137
- end
142
+ if ensure_builtin_gems_cached && spec.default_gem? && !cached_path(spec)
143
+ cached_built_in_gem(spec) unless spec.remote
144
+ force = true
138
145
  end
139
146
 
140
- if (installed?(spec) || Plugin.installed?(spec.name)) && !force
147
+ if installed?(spec) && !force
141
148
  print_using_message "Using #{version_message(spec)}"
142
149
  return nil # no post-install message
143
150
  end
144
151
 
145
- # Download the gem to get the spec, because some specs that are returned
146
- # by rubygems.org are broken and wrong.
147
152
  if spec.remote
148
153
  # Check for this spec from other sources
149
- uris = [spec.remote.anonymized_uri]
150
- uris += remotes_for_spec(spec).map(&:anonymized_uri)
151
- uris.uniq!
154
+ uris = [spec.remote, *remotes_for_spec(spec)].map(&:anonymized_uri).uniq
152
155
  Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1
156
+ end
157
+
158
+ path = fetch_gem_if_possible(spec, options[:previous_spec])
159
+ raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
160
+
161
+ return if Bundler.settings[:no_install]
162
+
163
+ if requires_sudo?
164
+ install_path = Bundler.tmp(spec.full_name)
165
+ bin_path = install_path.join("bin")
166
+ else
167
+ install_path = rubygems_dir
168
+ bin_path = Bundler.system_bindir
169
+ end
170
+
171
+ Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
172
+
173
+ require_relative "../rubygems_gem_installer"
174
+
175
+ installer = Bundler::RubyGemsGemInstaller.at(
176
+ path,
177
+ :security_policy => Bundler.rubygems.security_policies[Bundler.settings["trust-policy"]],
178
+ :install_dir => install_path.to_s,
179
+ :bin_dir => bin_path.to_s,
180
+ :ignore_dependencies => true,
181
+ :wrappers => true,
182
+ :env_shebang => true,
183
+ :build_args => options[:build_args],
184
+ :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
185
+ :bundler_extension_cache_path => extension_cache_path(spec)
186
+ )
153
187
 
154
- path = fetch_gem(spec)
155
- begin
156
- s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
157
- spec.__swap__(s)
158
- rescue StandardError
188
+ if spec.remote
189
+ s = begin
190
+ installer.spec
191
+ rescue Gem::Package::FormatError
159
192
  Bundler.rm_rf(path)
160
193
  raise
194
+ rescue Gem::Security::Exception => e
195
+ raise SecurityError,
196
+ "The gem #{File.basename(path, ".gem")} can't be installed because " \
197
+ "the security policy didn't allow it, with the message: #{e.message}"
161
198
  end
199
+
200
+ spec.__swap__(s)
162
201
  end
163
202
 
164
- unless Bundler.settings[:no_install]
165
- message = "Installing #{version_message(spec)}"
166
- message += " with native extensions" if spec.extensions.any?
167
- Bundler.ui.confirm message
203
+ message = "Installing #{version_message(spec, options[:previous_spec])}"
204
+ message += " with native extensions" if spec.extensions.any?
205
+ Bundler.ui.confirm message
168
206
 
169
- path = cached_gem(spec)
170
- if requires_sudo?
171
- install_path = Bundler.tmp(spec.full_name)
172
- bin_path = install_path.join("bin")
173
- else
174
- install_path = rubygems_dir
175
- bin_path = Bundler.system_bindir
176
- end
207
+ installed_spec = installer.install
177
208
 
178
- Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
179
-
180
- require_relative "../rubygems_gem_installer"
181
-
182
- installed_spec = Bundler::RubyGemsGemInstaller.at(
183
- path,
184
- :install_dir => install_path.to_s,
185
- :bin_dir => bin_path.to_s,
186
- :ignore_dependencies => true,
187
- :wrappers => true,
188
- :env_shebang => true,
189
- :build_args => opts[:build_args],
190
- :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
191
- :bundler_extension_cache_path => extension_cache_path(spec)
192
- ).install
193
- spec.full_gem_path = installed_spec.full_gem_path
194
-
195
- # SUDO HAX
196
- if requires_sudo?
197
- Bundler.rubygems.repository_subdirectories.each do |name|
198
- src = File.join(install_path, name, "*")
199
- dst = File.join(rubygems_dir, name)
200
- if name == "extensions" && Dir.glob(src).any?
201
- src = File.join(src, "*/*")
202
- ext_src = Dir.glob(src).first
203
- ext_src.gsub!(src[0..-6], "")
204
- dst = File.dirname(File.join(dst, ext_src))
205
- end
206
- SharedHelpers.filesystem_access(dst) do |p|
207
- Bundler.mkdir_p(p)
208
- end
209
- Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
209
+ spec.full_gem_path = installed_spec.full_gem_path
210
+ spec.loaded_from = installed_spec.loaded_from
211
+
212
+ # SUDO HAX
213
+ if requires_sudo?
214
+ Bundler.rubygems.repository_subdirectories.each do |name|
215
+ src = File.join(install_path, name, "*")
216
+ dst = File.join(rubygems_dir, name)
217
+ if name == "extensions" && Dir.glob(src).any?
218
+ src = File.join(src, "*/*")
219
+ ext_src = Dir.glob(src).first
220
+ ext_src.gsub!(src[0..-6], "")
221
+ dst = File.dirname(File.join(dst, ext_src))
222
+ end
223
+ SharedHelpers.filesystem_access(dst) do |p|
224
+ Bundler.mkdir_p(p)
210
225
  end
226
+ Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
227
+ end
211
228
 
212
- spec.executables.each do |exe|
213
- SharedHelpers.filesystem_access(Bundler.system_bindir) do |p|
214
- Bundler.mkdir_p(p)
215
- end
216
- Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/"
229
+ spec.executables.each do |exe|
230
+ SharedHelpers.filesystem_access(Bundler.system_bindir) do |p|
231
+ Bundler.mkdir_p(p)
217
232
  end
233
+ Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/"
218
234
  end
219
- installed_spec.loaded_from = loaded_from(spec)
220
235
  end
221
- spec.loaded_from = loaded_from(spec)
222
236
 
223
237
  spec.post_install_message
224
238
  ensure
@@ -226,12 +240,8 @@ module Bundler
226
240
  end
227
241
 
228
242
  def cache(spec, custom_path = nil)
229
- if builtin_gem?(spec)
230
- cached_path = cached_built_in_gem(spec)
231
- else
232
- cached_path = cached_gem(spec)
233
- end
234
- raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path
243
+ cached_path = Bundler.settings[:cache_all_platforms] ? fetch_gem_if_possible(spec) : cached_gem(spec)
244
+ raise GemNotFound, "Missing gem file '#{spec.file_name}'." unless cached_path
235
245
  return if File.dirname(cached_path) == Bundler.app_cache.to_s
236
246
  Bundler.ui.info " * #{File.basename(cached_path)}"
237
247
  FileUtils.cp(cached_path, Bundler.app_cache(custom_path))
@@ -258,10 +268,6 @@ module Bundler
258
268
  @remotes.unshift(uri) unless @remotes.include?(uri)
259
269
  end
260
270
 
261
- def equivalent_remotes?(other_remotes)
262
- other_remotes.map(&method(:remove_auth)) == @remotes.map(&method(:remove_auth))
263
- end
264
-
265
271
  def spec_names
266
272
  if @allow_remote && dependency_api_available?
267
273
  remote_specs.spec_names
@@ -330,7 +336,11 @@ module Bundler
330
336
  end
331
337
 
332
338
  def credless_remotes
333
- remotes.map(&method(:suppress_configured_credentials))
339
+ if Bundler.settings[:allow_deployment_source_credential_changes]
340
+ remotes.map(&method(:remove_auth))
341
+ else
342
+ remotes.map(&method(:suppress_configured_credentials))
343
+ end
334
344
  end
335
345
 
336
346
  def remotes_for_spec(spec)
@@ -340,23 +350,26 @@ module Bundler
340
350
  end
341
351
  end
342
352
 
343
- def loaded_from(spec)
344
- "#{rubygems_dir}/specifications/#{spec.full_name}.gemspec"
345
- end
346
-
347
353
  def cached_gem(spec)
348
- cached_gem = cached_path(spec)
349
- unless cached_gem
350
- raise Bundler::GemNotFound, "Could not find #{spec.file_name} for installation"
354
+ if spec.default_gem?
355
+ cached_built_in_gem(spec)
356
+ else
357
+ cached_path(spec)
351
358
  end
352
- cached_gem
353
359
  end
354
360
 
355
361
  def cached_path(spec)
356
- possibilities = @caches.map {|p| "#{p}/#{spec.file_name}" }
362
+ global_cache_path = download_cache_path(spec)
363
+ @caches << global_cache_path if global_cache_path
364
+
365
+ possibilities = @caches.map {|p| package_path(p, spec) }
357
366
  possibilities.find {|p| File.exist?(p) }
358
367
  end
359
368
 
369
+ def package_path(cache_path, spec)
370
+ "#{cache_path}/#{spec.file_name}"
371
+ end
372
+
360
373
  def normalize_uri(uri)
361
374
  uri = uri.to_s
362
375
  uri = "#{uri}/" unless uri =~ %r{/$}
@@ -447,24 +460,38 @@ module Bundler
447
460
  end
448
461
  end
449
462
 
450
- def fetch_gem(spec)
451
- return false unless spec.remote
463
+ def fetch_gem_if_possible(spec, previous_spec = nil)
464
+ if spec.remote
465
+ fetch_gem(spec, previous_spec)
466
+ else
467
+ cached_gem(spec)
468
+ end
469
+ end
452
470
 
471
+ def fetch_gem(spec, previous_spec = nil)
453
472
  spec.fetch_platform
454
473
 
455
- download_path = requires_sudo? ? Bundler.tmp(spec.full_name) : rubygems_dir
456
- gem_path = "#{rubygems_dir}/cache/#{spec.full_name}.gem"
474
+ cache_path = download_cache_path(spec) || default_cache_path_for(rubygems_dir)
475
+ gem_path = package_path(cache_path, spec)
476
+ return gem_path if File.exist?(gem_path)
457
477
 
458
- SharedHelpers.filesystem_access("#{download_path}/cache") do |p|
478
+ if requires_sudo?
479
+ download_path = Bundler.tmp(spec.full_name)
480
+ download_cache_path = default_cache_path_for(download_path)
481
+ else
482
+ download_cache_path = cache_path
483
+ end
484
+
485
+ SharedHelpers.filesystem_access(download_cache_path) do |p|
459
486
  FileUtils.mkdir_p(p)
460
487
  end
461
- download_gem(spec, download_path)
488
+ download_gem(spec, download_cache_path, previous_spec)
462
489
 
463
490
  if requires_sudo?
464
- SharedHelpers.filesystem_access("#{rubygems_dir}/cache") do |p|
491
+ SharedHelpers.filesystem_access(cache_path) do |p|
465
492
  Bundler.mkdir_p(p)
466
493
  end
467
- Bundler.sudo "mv #{download_path}/cache/#{spec.full_name}.gem #{gem_path}"
494
+ Bundler.sudo "mv #{package_path(download_cache_path, spec)} #{gem_path}"
468
495
  end
469
496
 
470
497
  gem_path
@@ -472,16 +499,8 @@ module Bundler
472
499
  Bundler.rm_rf(download_path) if requires_sudo?
473
500
  end
474
501
 
475
- def builtin_gem?(spec)
476
- # Ruby 2.1, where all included gems have this summary
477
- return true if spec.summary =~ /is bundled with Ruby/
478
-
479
- # Ruby 2.0, where gemspecs are stored in specifications/default/
480
- spec.loaded_from && spec.loaded_from.include?("specifications/default/")
481
- end
482
-
483
502
  def installed?(spec)
484
- installed_specs[spec].any?
503
+ installed_specs[spec].any? && !spec.deleted_gem?
485
504
  end
486
505
 
487
506
  def requires_sudo?
@@ -489,7 +508,11 @@ module Bundler
489
508
  end
490
509
 
491
510
  def rubygems_dir
492
- Bundler.rubygems.gem_dir
511
+ Bundler.bundle_path
512
+ end
513
+
514
+ def default_cache_path_for(dir)
515
+ "#{dir}/cache"
493
516
  end
494
517
 
495
518
  def cache_path
@@ -504,52 +527,16 @@ module Bundler
504
527
  # @param [Specification] spec
505
528
  # the spec we want to download or retrieve from the cache.
506
529
  #
507
- # @param [String] download_path
530
+ # @param [String] download_cache_path
508
531
  # the local directory the .gem will end up in.
509
532
  #
510
- def download_gem(spec, download_path)
511
- local_path = File.join(download_path, "cache/#{spec.full_name}.gem")
512
-
513
- if (cache_path = download_cache_path(spec)) && cache_path.file?
514
- SharedHelpers.filesystem_access(local_path) do
515
- FileUtils.cp(cache_path, local_path)
516
- end
517
- else
518
- uri = spec.remote.uri
519
- Bundler.ui.confirm("Fetching #{version_message(spec)}")
520
- rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, download_path)
521
-
522
- # older rubygems return varying file:// variants depending on version
523
- rubygems_local_path = rubygems_local_path.gsub(/\Afile:/, "") unless Bundler.rubygems.provides?(">= 3.2.0.rc.2")
524
- rubygems_local_path = rubygems_local_path.gsub(%r{\A//}, "") if Bundler.rubygems.provides?("< 3.1.0")
525
-
526
- if rubygems_local_path != local_path
527
- SharedHelpers.filesystem_access(local_path) do
528
- FileUtils.mv(rubygems_local_path, local_path)
529
- end
530
- end
531
- cache_globally(spec, local_path)
532
- end
533
- end
534
-
535
- # Checks if the requested spec exists in the global cache. If it does
536
- # not, we create the relevant global cache subdirectory if it does not
537
- # exist and copy the spec from the local cache to the global cache.
538
- #
539
- # @param [Specification] spec
540
- # the spec we want to copy to the global cache.
541
- #
542
- # @param [String] local_cache_path
543
- # the local directory from which we want to copy the .gem.
533
+ # @param [Specification] previous_spec
534
+ # the spec previously locked
544
535
  #
545
- def cache_globally(spec, local_cache_path)
546
- return unless cache_path = download_cache_path(spec)
547
- return if cache_path.exist?
548
-
549
- SharedHelpers.filesystem_access(cache_path.dirname, &:mkpath)
550
- SharedHelpers.filesystem_access(cache_path) do
551
- FileUtils.cp(local_cache_path, cache_path)
552
- end
536
+ def download_gem(spec, download_cache_path, previous_spec = nil)
537
+ uri = spec.remote.uri
538
+ Bundler.ui.confirm("Fetching #{version_message(spec, previous_spec)}")
539
+ Bundler.rubygems.download_gem(spec, uri, download_cache_path)
553
540
  end
554
541
 
555
542
  # Returns the global cache path of the calling Rubygems::Source object.
@@ -568,7 +555,7 @@ module Bundler
568
555
  return unless remote = spec.remote
569
556
  return unless cache_slug = remote.cache_slug
570
557
 
571
- Bundler.user_cache.join("gems", cache_slug, spec.file_name)
558
+ Bundler.user_cache.join("gems", cache_slug)
572
559
  end
573
560
 
574
561
  def extension_cache_slug(spec)
@@ -16,7 +16,7 @@ module Bundler
16
16
  @index
17
17
  end
18
18
 
19
- def to_err
19
+ def identifier
20
20
  to_s
21
21
  end
22
22
 
@@ -15,13 +15,12 @@ module Bundler
15
15
  specs.unmet_dependency_names
16
16
  end
17
17
 
18
- def version_message(spec)
18
+ def version_message(spec, locked_spec = nil)
19
19
  message = "#{spec.name} #{spec.version}"
20
20
  message += " (#{spec.platform})" if spec.platform != Gem::Platform::RUBY && !spec.platform.nil?
21
21
 
22
- if Bundler.locked_gems
23
- locked_spec = Bundler.locked_gems.specs.find {|s| s.name == spec.name }
24
- locked_spec_version = locked_spec.version if locked_spec
22
+ if locked_spec
23
+ locked_spec_version = locked_spec.version
25
24
  if locked_spec_version && spec.version != locked_spec_version
26
25
  message += Bundler.ui.add_color(" (was #{locked_spec_version})", version_color(spec.version, locked_spec_version))
27
26
  end
@@ -36,6 +35,8 @@ module Bundler
36
35
 
37
36
  def local!; end
38
37
 
38
+ def local_only!; end
39
+
39
40
  def cached!; end
40
41
 
41
42
  def remote!; end
@@ -65,7 +66,7 @@ module Bundler
65
66
  "#<#{self.class}:0x#{object_id} #{self}>"
66
67
  end
67
68
 
68
- def to_err
69
+ def identifier
69
70
  to_s
70
71
  end
71
72
 
@@ -98,7 +98,11 @@ module Bundler
98
98
  end
99
99
 
100
100
  def get(source)
101
- source_list_for(source).find {|s| equal_source?(source, s) || equivalent_source?(source, s) }
101
+ source_list_for(source).find {|s| equivalent_source?(source, s) }
102
+ end
103
+
104
+ def get_with_fallback(source)
105
+ get(source) || default_source
102
106
  end
103
107
 
104
108
  def lock_sources
@@ -106,14 +110,14 @@ module Bundler
106
110
  end
107
111
 
108
112
  def lock_other_sources
109
- (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
113
+ (path_sources + git_sources + plugin_sources).sort_by(&:identifier)
110
114
  end
111
115
 
112
116
  def lock_rubygems_sources
113
117
  if merged_gem_lockfile_sections?
114
118
  [combine_rubygems_sources]
115
119
  else
116
- rubygems_sources.sort_by(&:to_s)
120
+ rubygems_sources.sort_by(&:identifier)
117
121
  end
118
122
  end
119
123
 
@@ -136,6 +140,10 @@ module Bundler
136
140
  different_sources?(lock_sources, replacement_sources)
137
141
  end
138
142
 
143
+ def local_only!
144
+ all_sources.each(&:local_only!)
145
+ end
146
+
139
147
  def cached!
140
148
  all_sources.each(&:cached!)
141
149
  end
@@ -169,7 +177,7 @@ module Bundler
169
177
  end
170
178
 
171
179
  def different_sources?(lock_sources, replacement_sources)
172
- !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
180
+ !equivalent_sources?(lock_sources, replacement_sources)
173
181
  end
174
182
 
175
183
  def rubygems_aggregate_class
@@ -206,34 +214,12 @@ module Bundler
206
214
  end
207
215
  end
208
216
 
209
- def equal_sources?(lock_sources, replacement_sources)
210
- lock_sources.sort_by(&:to_s) == replacement_sources.sort_by(&:to_s)
211
- end
212
-
213
- def equal_source?(source, other_source)
214
- return source.include?(other_source) if source.is_a?(Source::Rubygems) && other_source.is_a?(Source::Rubygems)
215
-
216
- source == other_source
217
- end
218
-
219
- def equivalent_source?(source, other_source)
220
- return false unless Bundler.settings[:allow_deployment_source_credential_changes] && source.is_a?(Source::Rubygems)
221
-
222
- equivalent_rubygems_sources?([source], [other_source])
223
- end
224
-
225
217
  def equivalent_sources?(lock_sources, replacement_sources)
226
- return false unless Bundler.settings[:allow_deployment_source_credential_changes]
227
-
228
- lock_rubygems_sources, lock_other_sources = lock_sources.partition {|s| s.is_a?(Source::Rubygems) }
229
- replacement_rubygems_sources, replacement_other_sources = replacement_sources.partition {|s| s.is_a?(Source::Rubygems) }
230
-
231
- equivalent_rubygems_sources?(lock_rubygems_sources, replacement_rubygems_sources) && equal_sources?(lock_other_sources, replacement_other_sources)
218
+ lock_sources.sort_by(&:identifier) == replacement_sources.sort_by(&:identifier)
232
219
  end
233
220
 
234
- def equivalent_rubygems_sources?(lock_sources, replacement_sources)
235
- actual_remotes = replacement_sources.map(&:remotes).flatten.uniq
236
- lock_sources.all? {|s| s.equivalent_remotes?(actual_remotes) }
221
+ def equivalent_source?(source, other_source)
222
+ source == other_source
237
223
  end
238
224
  end
239
225
  end
@@ -2,11 +2,12 @@
2
2
 
3
3
  module Bundler
4
4
  class SourceMap
5
- attr_reader :sources, :dependencies
5
+ attr_reader :sources, :dependencies, :locked_specs
6
6
 
7
- def initialize(sources, dependencies)
7
+ def initialize(sources, dependencies, locked_specs)
8
8
  @sources = sources
9
9
  @dependencies = dependencies
10
+ @locked_specs = locked_specs
10
11
  end
11
12
 
12
13
  def pinned_spec_names(skip = nil)
@@ -54,5 +55,17 @@ module Bundler
54
55
  requirements
55
56
  end
56
57
  end
58
+
59
+ def locked_requirements
60
+ @locked_requirements ||= begin
61
+ requirements = {}
62
+ locked_specs.each do |locked_spec|
63
+ source = locked_spec.source
64
+ source.add_dependency_names(locked_spec.name)
65
+ requirements[locked_spec.name] = source
66
+ end
67
+ requirements
68
+ end
69
+ end
57
70
  end
58
71
  end