bundler 2.3.13 → 2.3.16

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/lib/bundler/build_metadata.rb +2 -2
  4. data/lib/bundler/cli/cache.rb +1 -1
  5. data/lib/bundler/cli/common.rb +1 -1
  6. data/lib/bundler/cli/install.rb +0 -2
  7. data/lib/bundler/cli.rb +2 -6
  8. data/lib/bundler/definition.rb +17 -21
  9. data/lib/bundler/dependency.rb +2 -0
  10. data/lib/bundler/dsl.rb +7 -11
  11. data/lib/bundler/errors.rb +14 -4
  12. data/lib/bundler/fetcher/base.rb +6 -8
  13. data/lib/bundler/fetcher.rb +4 -0
  14. data/lib/bundler/friendly_errors.rb +16 -2
  15. data/lib/bundler/gem_helpers.rb +1 -1
  16. data/lib/bundler/injector.rb +4 -0
  17. data/lib/bundler/inline.rb +1 -11
  18. data/lib/bundler/installer/gem_installer.rb +14 -1
  19. data/lib/bundler/installer.rb +2 -11
  20. data/lib/bundler/lazy_specification.rb +1 -1
  21. data/lib/bundler/man/bundle-add.1 +7 -3
  22. data/lib/bundler/man/bundle-add.1.ronn +5 -2
  23. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  24. data/lib/bundler/man/bundle-cache.1 +1 -1
  25. data/lib/bundler/man/bundle-check.1 +1 -1
  26. data/lib/bundler/man/bundle-clean.1 +1 -1
  27. data/lib/bundler/man/bundle-config.1 +1 -1
  28. data/lib/bundler/man/bundle-doctor.1 +1 -1
  29. data/lib/bundler/man/bundle-exec.1 +1 -1
  30. data/lib/bundler/man/bundle-gem.1 +1 -1
  31. data/lib/bundler/man/bundle-info.1 +1 -1
  32. data/lib/bundler/man/bundle-init.1 +1 -1
  33. data/lib/bundler/man/bundle-inject.1 +1 -1
  34. data/lib/bundler/man/bundle-install.1 +1 -1
  35. data/lib/bundler/man/bundle-list.1 +1 -1
  36. data/lib/bundler/man/bundle-lock.1 +1 -1
  37. data/lib/bundler/man/bundle-open.1 +1 -1
  38. data/lib/bundler/man/bundle-outdated.1 +1 -1
  39. data/lib/bundler/man/bundle-platform.1 +1 -1
  40. data/lib/bundler/man/bundle-pristine.1 +1 -1
  41. data/lib/bundler/man/bundle-remove.1 +1 -1
  42. data/lib/bundler/man/bundle-show.1 +1 -1
  43. data/lib/bundler/man/bundle-update.1 +1 -1
  44. data/lib/bundler/man/bundle-viz.1 +1 -1
  45. data/lib/bundler/man/bundle.1 +1 -1
  46. data/lib/bundler/man/gemfile.5 +1 -1
  47. data/lib/bundler/plugin/api/source.rb +3 -3
  48. data/lib/bundler/plugin/installer/git.rb +0 -4
  49. data/lib/bundler/plugin/installer/rubygems.rb +0 -4
  50. data/lib/bundler/process_lock.rb +1 -1
  51. data/lib/bundler/resolver.rb +17 -20
  52. data/lib/bundler/rubygems_ext.rb +1 -1
  53. data/lib/bundler/rubygems_gem_installer.rb +11 -8
  54. data/lib/bundler/rubygems_integration.rb +3 -21
  55. data/lib/bundler/settings.rb +1 -1
  56. data/lib/bundler/shared_helpers.rb +5 -5
  57. data/lib/bundler/source/git.rb +7 -9
  58. data/lib/bundler/source/path.rb +1 -1
  59. data/lib/bundler/source/rubygems.rb +90 -86
  60. data/lib/bundler/source.rb +3 -4
  61. data/lib/bundler/spec_set.rb +5 -3
  62. data/lib/bundler/stub_specification.rb +5 -3
  63. data/lib/bundler/version.rb +1 -1
  64. data/lib/bundler.rb +12 -1
  65. metadata +3 -3
@@ -135,17 +135,13 @@ module Bundler
135
135
  end
136
136
  end
137
137
 
138
- def install(spec, opts = {})
139
- force = opts[:force]
140
- ensure_builtin_gems_cached = opts[:ensure_builtin_gems_cached]
141
-
142
- if ensure_builtin_gems_cached && spec.default_gem?
143
- if !cached_path(spec)
144
- cached_built_in_gem(spec) unless spec.remote
145
- force = true
146
- else
147
- spec.loaded_from = loaded_from(spec)
148
- end
138
+ def install(spec, options = {})
139
+ force = options[:force]
140
+ ensure_builtin_gems_cached = options[:ensure_builtin_gems_cached]
141
+
142
+ if ensure_builtin_gems_cached && spec.default_gem? && !cached_path(spec)
143
+ cached_built_in_gem(spec) unless spec.remote
144
+ force = true
149
145
  end
150
146
 
151
147
  if installed?(spec) && !force
@@ -153,84 +149,90 @@ module Bundler
153
149
  return nil # no post-install message
154
150
  end
155
151
 
156
- # Download the gem to get the spec, because some specs that are returned
157
- # by rubygems.org are broken and wrong.
158
152
  if spec.remote
159
153
  # Check for this spec from other sources
160
- uris = [spec.remote.anonymized_uri]
161
- uris += remotes_for_spec(spec).map(&:anonymized_uri)
162
- uris.uniq!
154
+ uris = [spec.remote, *remotes_for_spec(spec)].map(&:anonymized_uri).uniq
163
155
  Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1
164
156
 
165
- path = fetch_gem(spec)
166
- begin
167
- s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
168
- spec.__swap__(s)
157
+ path = fetch_gem(spec, options[:previous_spec])
158
+ else
159
+ path = cached_gem(spec)
160
+ raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
161
+ end
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
+ )
187
+
188
+ if spec.remote
189
+ s = begin
190
+ installer.spec
169
191
  rescue Gem::Package::FormatError
170
192
  Bundler.rm_rf(path)
171
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}"
172
198
  end
199
+
200
+ spec.__swap__(s)
173
201
  end
174
202
 
175
- unless Bundler.settings[:no_install]
176
- message = "Installing #{version_message(spec)}"
177
- message += " with native extensions" if spec.extensions.any?
178
- 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
179
206
 
180
- path = cached_gem(spec)
181
- raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
182
- if requires_sudo?
183
- install_path = Bundler.tmp(spec.full_name)
184
- bin_path = install_path.join("bin")
185
- else
186
- install_path = rubygems_dir
187
- bin_path = Bundler.system_bindir
188
- end
207
+ installed_spec = installer.install
208
+
209
+ spec.full_gem_path = installed_spec.full_gem_path
210
+ spec.loaded_from = installed_spec.loaded_from
189
211
 
190
- Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
191
-
192
- require_relative "../rubygems_gem_installer"
193
-
194
- installed_spec = Bundler::RubyGemsGemInstaller.at(
195
- path,
196
- :install_dir => install_path.to_s,
197
- :bin_dir => bin_path.to_s,
198
- :ignore_dependencies => true,
199
- :wrappers => true,
200
- :env_shebang => true,
201
- :build_args => opts[:build_args],
202
- :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
203
- :bundler_extension_cache_path => extension_cache_path(spec)
204
- ).install
205
- spec.full_gem_path = installed_spec.full_gem_path
206
-
207
- # SUDO HAX
208
- if requires_sudo?
209
- Bundler.rubygems.repository_subdirectories.each do |name|
210
- src = File.join(install_path, name, "*")
211
- dst = File.join(rubygems_dir, name)
212
- if name == "extensions" && Dir.glob(src).any?
213
- src = File.join(src, "*/*")
214
- ext_src = Dir.glob(src).first
215
- ext_src.gsub!(src[0..-6], "")
216
- dst = File.dirname(File.join(dst, ext_src))
217
- end
218
- SharedHelpers.filesystem_access(dst) do |p|
219
- Bundler.mkdir_p(p)
220
- end
221
- Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
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)
222
225
  end
226
+ Bundler.sudo "cp -R #{src} #{dst}" if Dir[src].any?
227
+ end
223
228
 
224
- spec.executables.each do |exe|
225
- SharedHelpers.filesystem_access(Bundler.system_bindir) do |p|
226
- Bundler.mkdir_p(p)
227
- end
228
- 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)
229
232
  end
233
+ Bundler.sudo "cp -R #{install_path}/bin/#{exe} #{Bundler.system_bindir}/"
230
234
  end
231
- installed_spec.loaded_from = loaded_from(spec)
232
235
  end
233
- spec.loaded_from = loaded_from(spec)
234
236
 
235
237
  spec.post_install_message
236
238
  ensure
@@ -348,10 +350,6 @@ module Bundler
348
350
  end
349
351
  end
350
352
 
351
- def loaded_from(spec)
352
- "#{rubygems_dir}/specifications/#{spec.full_name}.gemspec"
353
- end
354
-
355
353
  def cached_gem(spec)
356
354
  if spec.default_gem?
357
355
  cached_built_in_gem(spec)
@@ -364,10 +362,14 @@ module Bundler
364
362
  global_cache_path = download_cache_path(spec)
365
363
  @caches << global_cache_path if global_cache_path
366
364
 
367
- possibilities = @caches.map {|p| "#{p}/#{spec.file_name}" }
365
+ possibilities = @caches.map {|p| package_path(p, spec) }
368
366
  possibilities.find {|p| File.exist?(p) }
369
367
  end
370
368
 
369
+ def package_path(cache_path, spec)
370
+ "#{cache_path}/#{spec.file_name}"
371
+ end
372
+
371
373
  def normalize_uri(uri)
372
374
  uri = uri.to_s
373
375
  uri = "#{uri}/" unless uri =~ %r{/$}
@@ -458,13 +460,12 @@ module Bundler
458
460
  end
459
461
  end
460
462
 
461
- def fetch_gem(spec)
462
- return false unless spec.remote
463
-
463
+ def fetch_gem(spec, previous_spec = nil)
464
464
  spec.fetch_platform
465
465
 
466
466
  cache_path = download_cache_path(spec) || default_cache_path_for(rubygems_dir)
467
- gem_path = "#{cache_path}/#{spec.file_name}"
467
+ gem_path = package_path(cache_path, spec)
468
+ return gem_path if File.exist?(gem_path)
468
469
 
469
470
  if requires_sudo?
470
471
  download_path = Bundler.tmp(spec.full_name)
@@ -476,13 +477,13 @@ module Bundler
476
477
  SharedHelpers.filesystem_access(download_cache_path) do |p|
477
478
  FileUtils.mkdir_p(p)
478
479
  end
479
- download_gem(spec, download_cache_path)
480
+ download_gem(spec, download_cache_path, previous_spec)
480
481
 
481
482
  if requires_sudo?
482
483
  SharedHelpers.filesystem_access(cache_path) do |p|
483
484
  Bundler.mkdir_p(p)
484
485
  end
485
- Bundler.sudo "mv #{download_cache_path}/#{spec.file_name} #{gem_path}"
486
+ Bundler.sudo "mv #{package_path(download_cache_path, spec)} #{gem_path}"
486
487
  end
487
488
 
488
489
  gem_path
@@ -499,7 +500,7 @@ module Bundler
499
500
  end
500
501
 
501
502
  def rubygems_dir
502
- Bundler.rubygems.gem_dir
503
+ Bundler.bundle_path
503
504
  end
504
505
 
505
506
  def default_cache_path_for(dir)
@@ -521,9 +522,12 @@ module Bundler
521
522
  # @param [String] download_cache_path
522
523
  # the local directory the .gem will end up in.
523
524
  #
524
- def download_gem(spec, download_cache_path)
525
+ # @param [Specification] previous_spec
526
+ # the spec previously locked
527
+ #
528
+ def download_gem(spec, download_cache_path, previous_spec = nil)
525
529
  uri = spec.remote.uri
526
- Bundler.ui.confirm("Fetching #{version_message(spec)}")
530
+ Bundler.ui.confirm("Fetching #{version_message(spec, previous_spec)}")
527
531
  Bundler.rubygems.download_gem(spec, uri, download_cache_path)
528
532
  end
529
533
 
@@ -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
@@ -18,13 +18,13 @@ module Bundler
18
18
 
19
19
  loop do
20
20
  break unless dep = deps.shift
21
- next if handled.any?{|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
21
+ next if handled.any? {|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
22
22
 
23
23
  handled << dep
24
24
 
25
25
  specs_for_dep = spec_for_dependency(dep, match_current_platform)
26
26
  if specs_for_dep.any?
27
- match_current_platform ? specs += specs_for_dep : specs |= specs_for_dep
27
+ specs.concat(specs_for_dep)
28
28
 
29
29
  specs_for_dep.first.dependencies.each do |d|
30
30
  next if d.type == :development
@@ -40,6 +40,8 @@ module Bundler
40
40
  specs << spec
41
41
  end
42
42
 
43
+ specs.uniq! unless match_current_platform
44
+
43
45
  check ? true : specs
44
46
  end
45
47
 
@@ -172,7 +174,7 @@ module Bundler
172
174
  def spec_for_dependency(dep, match_current_platform)
173
175
  specs_for_platforms = lookup[dep.name]
174
176
  if match_current_platform
175
- GemHelpers.select_best_platform_match(specs_for_platforms.select{|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
177
+ GemHelpers.select_best_platform_match(specs_for_platforms.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
176
178
  else
177
179
  GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
178
180
  end
@@ -64,9 +64,11 @@ module Bundler
64
64
  end
65
65
 
66
66
  def full_gem_path
67
- # deleted gems can have their stubs return nil, so in that case grab the
68
- # expired path from the full spec
69
- stub.full_gem_path || method_missing(:full_gem_path)
67
+ stub.full_gem_path
68
+ end
69
+
70
+ def full_gem_path=(path)
71
+ stub.full_gem_path = path
70
72
  end
71
73
 
72
74
  def full_require_paths
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.3.13".freeze
4
+ VERSION = "2.3.16".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
data/lib/bundler.rb CHANGED
@@ -19,7 +19,7 @@ require_relative "bundler/build_metadata"
19
19
  #
20
20
  # Since Ruby 2.6, Bundler is a part of Ruby's standard library.
21
21
  #
22
- # Bunder is used by creating _gemfiles_ listing all the project dependencies
22
+ # Bundler is used by creating _gemfiles_ listing all the project dependencies
23
23
  # and (optionally) their versions and then using
24
24
  #
25
25
  # require 'bundler/setup'
@@ -97,6 +97,17 @@ module Bundler
97
97
  @bundle_path ||= Pathname.new(configured_bundle_path.path).expand_path(root)
98
98
  end
99
99
 
100
+ def create_bundle_path
101
+ SharedHelpers.filesystem_access(bundle_path.to_s) do |p|
102
+ mkdir_p(p)
103
+ end unless bundle_path.exist?
104
+
105
+ @bundle_path = bundle_path.realpath
106
+ rescue Errno::EEXIST
107
+ raise PathError, "Could not install to path `#{bundle_path}` " \
108
+ "because a file already exists at that path. Either remove or rename the file so the directory can be created."
109
+ end
110
+
100
111
  def configured_bundle_path
101
112
  @configured_bundle_path ||= settings.path.tap(&:validate!)
102
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.13
4
+ version: 2.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Arko
@@ -22,7 +22,7 @@ authors:
22
22
  autorequire:
23
23
  bindir: exe
24
24
  cert_chain: []
25
- date: 2022-05-04 00:00:00.000000000 Z
25
+ date: 2022-06-15 00:00:00.000000000 Z
26
26
  dependencies: []
27
27
  description: Bundler manages an application's dependencies through its entire life,
28
28
  across many machines, systematically and repeatably
@@ -369,7 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
369
369
  - !ruby/object:Gem::Version
370
370
  version: 2.5.2
371
371
  requirements: []
372
- rubygems_version: 3.3.13
372
+ rubygems_version: 3.3.16
373
373
  signing_key:
374
374
  specification_version: 4
375
375
  summary: The best way to manage your application's dependencies