bundler 2.4.20 → 2.4.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +55 -3
  3. data/README.md +1 -2
  4. data/lib/bundler/build_metadata.rb +3 -3
  5. data/lib/bundler/cli/check.rb +1 -1
  6. data/lib/bundler/cli/gem.rb +4 -3
  7. data/lib/bundler/cli/install.rb +2 -2
  8. data/lib/bundler/cli/lock.rb +26 -23
  9. data/lib/bundler/cli/open.rb +5 -7
  10. data/lib/bundler/definition.rb +43 -26
  11. data/lib/bundler/endpoint_specification.rb +1 -1
  12. data/lib/bundler/env.rb +2 -2
  13. data/lib/bundler/errors.rb +15 -0
  14. data/lib/bundler/gem_helpers.rb +7 -0
  15. data/lib/bundler/gem_version_promoter.rb +2 -2
  16. data/lib/bundler/injector.rb +1 -1
  17. data/lib/bundler/installer/gem_installer.rb +5 -5
  18. data/lib/bundler/installer/parallel_installer.rb +0 -26
  19. data/lib/bundler/installer/standalone.rb +13 -6
  20. data/lib/bundler/lazy_specification.rb +4 -0
  21. data/lib/bundler/lockfile_parser.rb +29 -24
  22. data/lib/bundler/man/bundle-add.1 +1 -1
  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-console.1 +1 -1
  29. data/lib/bundler/man/bundle-doctor.1 +1 -1
  30. data/lib/bundler/man/bundle-exec.1 +2 -2
  31. data/lib/bundler/man/bundle-exec.1.ronn +2 -3
  32. data/lib/bundler/man/bundle-gem.1 +1 -1
  33. data/lib/bundler/man/bundle-help.1 +1 -1
  34. data/lib/bundler/man/bundle-info.1 +1 -1
  35. data/lib/bundler/man/bundle-init.1 +1 -1
  36. data/lib/bundler/man/bundle-inject.1 +1 -1
  37. data/lib/bundler/man/bundle-install.1 +1 -1
  38. data/lib/bundler/man/bundle-list.1 +1 -1
  39. data/lib/bundler/man/bundle-lock.1 +1 -1
  40. data/lib/bundler/man/bundle-open.1 +1 -1
  41. data/lib/bundler/man/bundle-outdated.1 +1 -1
  42. data/lib/bundler/man/bundle-platform.1 +1 -1
  43. data/lib/bundler/man/bundle-plugin.1 +17 -17
  44. data/lib/bundler/man/bundle-plugin.1.ronn +5 -5
  45. data/lib/bundler/man/bundle-pristine.1 +1 -1
  46. data/lib/bundler/man/bundle-remove.1 +1 -1
  47. data/lib/bundler/man/bundle-show.1 +1 -1
  48. data/lib/bundler/man/bundle-update.1 +1 -1
  49. data/lib/bundler/man/bundle-version.1 +1 -1
  50. data/lib/bundler/man/bundle-viz.1 +1 -1
  51. data/lib/bundler/man/bundle.1 +1 -1
  52. data/lib/bundler/man/gemfile.5 +1 -1
  53. data/lib/bundler/plugin/index.rb +8 -0
  54. data/lib/bundler/plugin.rb +9 -2
  55. data/lib/bundler/resolver/package.rb +5 -0
  56. data/lib/bundler/resolver.rb +27 -7
  57. data/lib/bundler/ruby_version.rb +8 -1
  58. data/lib/bundler/rubygems_ext.rb +3 -4
  59. data/lib/bundler/rubygems_gem_installer.rb +23 -8
  60. data/lib/bundler/settings.rb +53 -16
  61. data/lib/bundler/shared_helpers.rb +16 -1
  62. data/lib/bundler/source/git/git_proxy.rb +21 -4
  63. data/lib/bundler/source/metadata.rb +1 -1
  64. data/lib/bundler/spec_set.rb +7 -4
  65. data/lib/bundler/stub_specification.rb +4 -2
  66. data/lib/bundler/templates/newgem/Rakefile.tt +6 -2
  67. data/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
  68. data/lib/bundler/ui/shell.rb +1 -1
  69. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +1 -0
  70. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +21 -9
  71. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  72. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
  73. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  74. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  75. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +8 -10
  76. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +15 -4
  77. data/lib/bundler/vendor/thor/lib/thor/actions.rb +15 -15
  78. data/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
  79. data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
  80. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +4 -0
  81. data/lib/bundler/vendor/thor/lib/thor/error.rb +16 -25
  82. data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  83. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
  84. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
  85. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
  86. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
  87. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
  88. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +44 -6
  89. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
  90. data/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
  91. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +26 -150
  92. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +4 -46
  93. data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  94. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -45
  95. data/lib/bundler/vendor/thor/lib/thor/shell/lcs_diff.rb +49 -0
  96. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
  97. data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  98. data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  99. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  100. data/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  101. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  102. data/lib/bundler/vendor/thor/lib/thor.rb +155 -8
  103. data/lib/bundler/version.rb +1 -1
  104. data/lib/bundler/yaml_serializer.rb +12 -8
  105. data/lib/bundler.rb +0 -8
  106. metadata +8 -3
@@ -131,7 +131,7 @@ module Bundler
131
131
 
132
132
  if base_requirements[name]
133
133
  names_to_unlock << name
134
- elsif package.ignores_prereleases?
134
+ elsif package.ignores_prereleases? && @all_specs[name].any? {|s| s.version.prerelease? }
135
135
  names_to_allow_prereleases_for << name
136
136
  end
137
137
 
@@ -248,8 +248,22 @@ module Bundler
248
248
  results = filter_matching_specs(results, locked_requirement) if locked_requirement
249
249
 
250
250
  versions = results.group_by(&:version).reduce([]) do |groups, (version, specs)|
251
- platform_specs = package.platforms.flat_map {|platform| select_best_platform_match(specs, platform) }
252
- next groups if platform_specs.empty?
251
+ platform_specs = package.platforms.map {|platform| select_best_platform_match(specs, platform) }
252
+
253
+ # If package is a top-level dependency,
254
+ # candidate is only valid if there are matching versions for all resolution platforms.
255
+ #
256
+ # If package is not a top-level deependency,
257
+ # then it's not necessary that it has matching versions for all platforms, since it may have been introduced only as
258
+ # a dependency for a platform specific variant, so it will only need to have a valid version for that platform.
259
+ #
260
+ if package.top_level?
261
+ next groups if platform_specs.any?(&:empty?)
262
+ else
263
+ next groups if platform_specs.all?(&:empty?)
264
+ end
265
+
266
+ platform_specs.flatten!
253
267
 
254
268
  ruby_specs = select_best_platform_match(specs, Gem::Platform::RUBY)
255
269
  groups << Resolver::Candidate.new(version, :specs => ruby_specs) if ruby_specs.any?
@@ -295,15 +309,21 @@ module Bundler
295
309
  end
296
310
  specs_matching_requirement = filter_matching_specs(specs, package.dependency.requirement)
297
311
 
298
- if specs_matching_requirement.any?
312
+ not_found_message = if specs_matching_requirement.any?
299
313
  specs = specs_matching_requirement
300
314
  matching_part = requirement_label
301
315
  platforms = package.platforms
302
- platform_label = platforms.size == 1 ? "platform '#{platforms.first}" : "platforms '#{platforms.join("', '")}"
303
- requirement_label = "#{requirement_label}' with #{platform_label}"
316
+
317
+ if platforms.size == 1
318
+ "Could not find gem '#{requirement_label}' with platform '#{platforms.first}'"
319
+ else
320
+ "Could not find gems matching '#{requirement_label}' valid for all resolution platforms (#{platforms.join(", ")})"
321
+ end
322
+ else
323
+ "Could not find gem '#{requirement_label}'"
304
324
  end
305
325
 
306
- message = String.new("Could not find gem '#{requirement_label}' in #{source}#{cache_message}.\n")
326
+ message = String.new("#{not_found_message} in #{source}#{cache_message}.\n")
307
327
 
308
328
  if specs.any?
309
329
  message << "\n#{other_specs_matching_message(specs, matching_part)}"
@@ -23,7 +23,7 @@ module Bundler
23
23
  # specified must match the version.
24
24
 
25
25
  @versions = Array(versions).map do |v|
26
- op, v = Gem::Requirement.parse(v)
26
+ op, v = Gem::Requirement.parse(normalize_version(v))
27
27
  op == "=" ? v.to_s : "#{op} #{v}"
28
28
  end
29
29
 
@@ -112,6 +112,13 @@ module Bundler
112
112
 
113
113
  private
114
114
 
115
+ # Ruby's official preview version format uses a `-`: Example: 3.3.0-preview2
116
+ # However, RubyGems recognizes preview version format with a `.`: Example: 3.3.0.preview2
117
+ # Returns version string after replacing `-` with `.`
118
+ def normalize_version(version)
119
+ version.tr("-", ".")
120
+ end
121
+
115
122
  def matches?(requirements, version)
116
123
  # Handles RUBY_PATCHLEVEL of -1 for instances like ruby-head
117
124
  return requirements == version if requirements.to_s == "-1" || version.to_s == "-1"
@@ -320,7 +320,7 @@ module Gem
320
320
  end
321
321
 
322
322
  # On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory.
323
- class Specification
323
+ class BasicSpecification
324
324
  if /^universal\.(?<arch>.*?)-/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
325
325
  local_platform = Platform.local
326
326
  if local_platform.cpu == "universal"
@@ -333,9 +333,8 @@ module Gem
333
333
  end
334
334
 
335
335
  def extensions_dir
336
- Gem.default_ext_dir_for(base_dir) ||
337
- File.join(base_dir, "extensions", ORIGINAL_LOCAL_PLATFORM,
338
- Gem.extension_api_version)
336
+ @extensions_dir ||=
337
+ Gem.default_ext_dir_for(base_dir) || File.join(base_dir, "extensions", ORIGINAL_LOCAL_PLATFORM, Gem.extension_api_version)
339
338
  end
340
339
  end
341
340
  end
@@ -45,6 +45,14 @@ module Bundler
45
45
  spec
46
46
  end
47
47
 
48
+ def pre_install_checks
49
+ super && validate_bundler_checksum(options[:bundler_expected_checksum])
50
+ rescue Gem::FilePermissionError
51
+ # Ignore permission checks in RubyGems. Instead, go on, and try to write
52
+ # for real. We properly handle permission errors when they happen.
53
+ nil
54
+ end
55
+
48
56
  def generate_plugins
49
57
  return unless Gem::Installer.instance_methods(false).include?(:generate_plugins)
50
58
 
@@ -60,10 +68,6 @@ module Bundler
60
68
  end
61
69
  end
62
70
 
63
- def pre_install_checks
64
- super && validate_bundler_checksum(options[:bundler_expected_checksum])
65
- end
66
-
67
71
  def build_extensions
68
72
  extension_cache_path = options[:bundler_extension_cache_path]
69
73
  extension_dir = spec.extension_dir
@@ -108,11 +112,22 @@ module Bundler
108
112
  end
109
113
 
110
114
  def strict_rm_rf(dir)
111
- Bundler.rm_rf dir
112
- rescue StandardError => e
113
- raise unless File.exist?(dir)
115
+ return unless File.exist?(dir)
116
+
117
+ parent = File.dirname(dir)
118
+ parent_st = File.stat(parent)
119
+
120
+ if parent_st.world_writable? && !parent_st.sticky?
121
+ raise InsecureInstallPathError.new(parent)
122
+ end
123
+
124
+ begin
125
+ FileUtils.remove_entry_secure(dir)
126
+ rescue StandardError => e
127
+ raise unless File.exist?(dir)
114
128
 
115
- raise DirectoryRemovalError.new(e, "Could not delete previous installation of `#{dir}`")
129
+ raise DirectoryRemovalError.new(e, "Could not delete previous installation of `#{dir}`")
130
+ end
116
131
  end
117
132
 
118
133
  def validate_bundler_checksum(checksum)
@@ -95,6 +95,8 @@ module Bundler
95
95
 
96
96
  @global_config = load_config(global_config_file)
97
97
  @temporary = {}
98
+
99
+ @key_cache = {}
98
100
  end
99
101
 
100
102
  def [](name)
@@ -310,7 +312,7 @@ module Bundler
310
312
  end
311
313
 
312
314
  def key_for(key)
313
- self.class.key_for(key)
315
+ @key_cache[key] ||= self.class.key_for(key)
314
316
  end
315
317
 
316
318
  private
@@ -342,12 +344,12 @@ module Bundler
342
344
  end
343
345
 
344
346
  def is_bool(name)
345
- name = name.to_s
347
+ name = self.class.key_to_s(name)
346
348
  BOOL_KEYS.include?(name) || BOOL_KEYS.include?(parent_setting_for(name))
347
349
  end
348
350
 
349
351
  def is_string(name)
350
- name = name.to_s
352
+ name = self.class.key_to_s(name)
351
353
  STRING_KEYS.include?(name) || name.start_with?("local.") || name.start_with?("mirror.") || name.start_with?("build.")
352
354
  end
353
355
 
@@ -363,11 +365,11 @@ module Bundler
363
365
  end
364
366
 
365
367
  def is_num(key)
366
- NUMBER_KEYS.include?(key.to_s)
368
+ NUMBER_KEYS.include?(self.class.key_to_s(key))
367
369
  end
368
370
 
369
371
  def is_array(key)
370
- ARRAY_KEYS.include?(key.to_s)
372
+ ARRAY_KEYS.include?(self.class.key_to_s(key))
371
373
  end
372
374
 
373
375
  def is_credential(key)
@@ -390,7 +392,7 @@ module Bundler
390
392
  end
391
393
 
392
394
  def set_key(raw_key, value, hash, file)
393
- raw_key = raw_key.to_s
395
+ raw_key = self.class.key_to_s(raw_key)
394
396
  value = array_to_s(value) if is_array(raw_key)
395
397
 
396
398
  key = key_for(raw_key)
@@ -405,13 +407,12 @@ module Bundler
405
407
  return unless file
406
408
  SharedHelpers.filesystem_access(file) do |p|
407
409
  FileUtils.mkdir_p(p.dirname)
408
- require_relative "yaml_serializer"
409
- p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
410
+ p.open("w") {|f| f.write(serializer_class.dump(hash)) }
410
411
  end
411
412
  end
412
413
 
413
414
  def converted_value(value, key)
414
- key = key.to_s
415
+ key = self.class.key_to_s(key)
415
416
 
416
417
  if is_array(key)
417
418
  to_array(value)
@@ -470,24 +471,31 @@ module Bundler
470
471
  SharedHelpers.filesystem_access(config_file, :read) do |file|
471
472
  valid_file = file.exist? && !file.size.zero?
472
473
  return {} unless valid_file
473
- require_relative "yaml_serializer"
474
- YAMLSerializer.load(file.read).inject({}) do |config, (k, v)|
475
- new_k = k
476
-
474
+ serializer_class.load(file.read).inject({}) do |config, (k, v)|
477
475
  if k.include?("-")
478
476
  Bundler.ui.warn "Your #{file} config includes `#{k}`, which contains the dash character (`-`).\n" \
479
477
  "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n" \
480
478
  "Please edit #{file} and replace any dashes in configuration keys with a triple underscore (`___`)."
481
479
 
482
- new_k = k.gsub("-", "___")
480
+ # string hash keys are frozen
481
+ k = k.gsub("-", "___")
483
482
  end
484
483
 
485
- config[new_k] = v
484
+ config[k] = v
486
485
  config
487
486
  end
488
487
  end
489
488
  end
490
489
 
490
+ def serializer_class
491
+ require "rubygems/yaml_serializer"
492
+ Gem::YAMLSerializer
493
+ rescue LoadError
494
+ # TODO: Remove this when RubyGems 3.4 is EOL
495
+ require_relative "yaml_serializer"
496
+ YAMLSerializer
497
+ end
498
+
491
499
  PER_URI_OPTIONS = %w[
492
500
  fallback_timeout
493
501
  ].freeze
@@ -503,7 +511,7 @@ module Bundler
503
511
 
504
512
  def self.key_for(key)
505
513
  key = normalize_uri(key).to_s if key.is_a?(String) && key.start_with?("http", "mirror.http")
506
- key = key.to_s.gsub(".", "__")
514
+ key = key_to_s(key).gsub(".", "__")
507
515
  key.gsub!("-", "___")
508
516
  key.upcase!
509
517
 
@@ -527,5 +535,34 @@ module Bundler
527
535
  end
528
536
  "#{prefix}#{uri}#{suffix}"
529
537
  end
538
+
539
+ # This is a hot method, so avoid respond_to? checks on every invocation
540
+ if :read.respond_to?(:name)
541
+ def self.key_to_s(key)
542
+ case key
543
+ when String
544
+ key
545
+ when Symbol
546
+ key.name
547
+ when Bundler::URI::HTTP
548
+ key.to_s
549
+ else
550
+ raise ArgumentError, "Invalid key: #{key.inspect}"
551
+ end
552
+ end
553
+ else
554
+ def self.key_to_s(key)
555
+ case key
556
+ when String
557
+ key
558
+ when Symbol
559
+ key.to_s
560
+ when Bundler::URI::HTTP
561
+ key.to_s
562
+ else
563
+ raise ArgumentError, "Invalid key: #{key.inspect}"
564
+ end
565
+ end
566
+ end
530
567
  end
531
568
  end
@@ -197,6 +197,21 @@ module Bundler
197
197
  filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } }
198
198
  end
199
199
 
200
+ def relative_gemfile_path
201
+ relative_path_to(Bundler.default_gemfile)
202
+ end
203
+
204
+ def relative_lockfile_path
205
+ relative_path_to(Bundler.default_lockfile)
206
+ end
207
+
208
+ def relative_path_to(destination, from: pwd)
209
+ Pathname.new(destination).relative_path_from(from).to_s
210
+ rescue ArgumentError
211
+ # on Windows, if source and destination are on different drivers, there's no relative path from one to the other
212
+ destination
213
+ end
214
+
200
215
  private
201
216
 
202
217
  def validate_bundle_path
@@ -297,7 +312,7 @@ module Bundler
297
312
  def set_rubyopt
298
313
  rubyopt = [ENV["RUBYOPT"]].compact
299
314
  setup_require = "-r#{File.expand_path("setup", __dir__)}"
300
- return if !rubyopt.empty? && rubyopt.first =~ /#{setup_require}/
315
+ return if !rubyopt.empty? && rubyopt.first =~ /#{Regexp.escape(setup_require)}/
301
316
  rubyopt.unshift setup_require
302
317
  Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
303
318
  end
@@ -130,7 +130,12 @@ module Bundler
130
130
  end
131
131
  end
132
132
 
133
- git "fetch", "--force", "--quiet", *extra_fetch_args, :dir => destination if @commit_ref
133
+ ref = @commit_ref || (locked_to_full_sha? && @revision)
134
+ if ref
135
+ git "config", "uploadpack.allowAnySHA1InWant", "true", :dir => path.to_s if @commit_ref.nil? && needs_allow_any_sha1_in_want?
136
+
137
+ git "fetch", "--force", "--quiet", *extra_fetch_args(ref), :dir => destination
138
+ end
134
139
 
135
140
  git "reset", "--hard", @revision, :dir => destination
136
141
 
@@ -247,7 +252,15 @@ module Bundler
247
252
  end
248
253
 
249
254
  def pinned_to_full_sha?
250
- ref =~ /\A\h{40}\z/
255
+ full_sha_revision?(ref)
256
+ end
257
+
258
+ def locked_to_full_sha?
259
+ full_sha_revision?(@revision)
260
+ end
261
+
262
+ def full_sha_revision?(ref)
263
+ ref&.match?(/\A\h{40}\z/)
251
264
  end
252
265
 
253
266
  def git_null(*command, dir: nil)
@@ -411,9 +424,9 @@ module Bundler
411
424
  ["--depth", depth.to_s]
412
425
  end
413
426
 
414
- def extra_fetch_args
427
+ def extra_fetch_args(ref)
415
428
  extra_args = [path.to_s, *depth_args]
416
- extra_args.push(@commit_ref)
429
+ extra_args.push(ref)
417
430
  extra_args
418
431
  end
419
432
 
@@ -425,6 +438,10 @@ module Bundler
425
438
  @supports_minus_c ||= Gem::Version.new(version) >= Gem::Version.new("1.8.5")
426
439
  end
427
440
 
441
+ def needs_allow_any_sha1_in_want?
442
+ @needs_allow_any_sha1_in_want ||= Gem::Version.new(version) <= Gem::Version.new("2.13.7")
443
+ end
444
+
428
445
  def supports_fetching_unreachable_refs?
429
446
  @supports_fetching_unreachable_refs ||= Gem::Version.new(version) >= Gem::Version.new("2.5.0")
430
447
  end
@@ -5,7 +5,7 @@ module Bundler
5
5
  class Metadata < Source
6
6
  def specs
7
7
  @specs ||= Index.build do |idx|
8
- idx << Gem::Specification.new("Ruby\0", Gem.ruby_version)
8
+ idx << Gem::Specification.new("Ruby\0", Bundler::RubyVersion.system.gem_version)
9
9
  idx << Gem::Specification.new("RubyGems\0", Gem::VERSION) do |s|
10
10
  s.required_rubygems_version = Gem::Requirement.default
11
11
  end
@@ -100,12 +100,12 @@ module Bundler
100
100
  end
101
101
  end
102
102
 
103
- def incomplete_ruby_specs?(deps)
103
+ def incomplete_for_platform?(deps, platform)
104
104
  return false if @specs.empty?
105
105
 
106
106
  @incomplete_specs = []
107
107
 
108
- self.for(deps, true, [Gem::Platform::RUBY])
108
+ self.for(deps, true, [platform])
109
109
 
110
110
  @incomplete_specs.any?
111
111
  end
@@ -200,8 +200,11 @@ module Bundler
200
200
 
201
201
  def specs_for_dependency(dep, platform)
202
202
  specs_for_name = lookup[dep.name]
203
- target_platform = dep.force_ruby_platform ? Gem::Platform::RUBY : (platform || Bundler.local_platform)
204
- matching_specs = GemHelpers.select_best_platform_match(specs_for_name, target_platform)
203
+ matching_specs = if dep.force_ruby_platform
204
+ GemHelpers.force_ruby_platform(specs_for_name)
205
+ else
206
+ GemHelpers.select_best_platform_match(specs_for_name, platform || Bundler.local_platform)
207
+ end
205
208
  matching_specs.map!(&:materialize_for_installation).compact! if platform.nil?
206
209
  matching_specs
207
210
  end
@@ -16,7 +16,8 @@ module Bundler
16
16
  # Stub has no concept of source, which means that extension_dir may be wrong
17
17
  # This is the case for git-based gems. So, instead manually assign the extension dir
18
18
  return unless source.respond_to?(:extension_dir_name)
19
- path = File.join(stub.extensions_dir, source.extension_dir_name)
19
+ unique_extension_dir = [source.extension_dir_name, File.basename(full_gem_path)].uniq.join("-")
20
+ path = File.join(stub.extensions_dir, unique_extension_dir)
20
21
  stub.extension_dir = File.expand_path(path)
21
22
  end
22
23
 
@@ -56,7 +57,7 @@ module Bundler
56
57
  end
57
58
 
58
59
  def gem_build_complete_path
59
- File.join(extension_dir, "gem.build_complete")
60
+ stub.gem_build_complete_path
60
61
  end
61
62
 
62
63
  def default_gem?
@@ -108,6 +109,7 @@ module Bundler
108
109
  end
109
110
 
110
111
  rs.source = source
112
+ rs.base_dir = stub.base_dir
111
113
 
112
114
  rs
113
115
  end
@@ -46,7 +46,9 @@ require "rb_sys/extensiontask"
46
46
 
47
47
  task build: :compile
48
48
 
49
- RbSys::ExtensionTask.new(<%= config[:name].inspect %>) do |ext|
49
+ GEMSPEC = Gem::Specification.load("<%= config[:underscored_name] %>.gemspec")
50
+
51
+ RbSys::ExtensionTask.new(<%= config[:name].inspect %>, GEMSPEC) do |ext|
50
52
  ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
51
53
  end
52
54
  <% else -%>
@@ -54,7 +56,9 @@ require "rake/extensiontask"
54
56
 
55
57
  task build: :compile
56
58
 
57
- Rake::ExtensionTask.new("<%= config[:underscored_name] %>") do |ext|
59
+ GEMSPEC = Gem::Specification.load("<%= config[:underscored_name] %>.gemspec")
60
+
61
+ Rake::ExtensionTask.new("<%= config[:underscored_name] %>", GEMSPEC) do |ext|
58
62
  ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
59
63
  end
60
64
  <% end -%>
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.files = Dir.chdir(__dir__) do
31
31
  `git ls-files -z`.split("\x0").reject do |f|
32
32
  (File.expand_path(f) == __FILE__) ||
33
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
33
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git <%= config[:ci_config_path] %>appveyor Gemfile])
34
34
  end
35
35
  end
36
36
  spec.bindir = "exe"
@@ -147,7 +147,7 @@ module Bundler
147
147
  spaces ? text.gsub(/#{spaces}/, "") : text
148
148
  end
149
149
 
150
- def word_wrap(text, line_width = @shell.terminal_width)
150
+ def word_wrap(text, line_width = Thor::Terminal.terminal_width)
151
151
  strip_leading_spaces(text).split("\n").collect do |line|
152
152
  line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
153
153
  end * "\n"
@@ -25,6 +25,7 @@ class Bundler::Persistent::Net::HTTP::Persistent::Connection # :nodoc:
25
25
  ensure
26
26
  reset
27
27
  end
28
+ alias_method :close, :finish
28
29
 
29
30
  def reset
30
31
  @last_use = Bundler::Persistent::Net::HTTP::Persistent::EPOCH
@@ -11,20 +11,32 @@ class Bundler::Persistent::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool
11
11
  end
12
12
 
13
13
  def checkin net_http_args
14
- stack = Thread.current[@key][net_http_args] ||= []
14
+ if net_http_args.is_a?(Hash) && net_http_args.size == 1 && net_http_args[:force]
15
+ # Bundler::ConnectionPool 2.4+ calls `checkin(force: true)` after fork.
16
+ # When this happens, we should remove all connections from Thread.current
17
+ if stacks = Thread.current[@key]
18
+ stacks.each do |http_args, connections|
19
+ connections.each do |conn|
20
+ @available.push conn, connection_args: http_args
21
+ end
22
+ connections.clear
23
+ end
24
+ end
25
+ else
26
+ stack = Thread.current[@key][net_http_args] ||= []
15
27
 
16
- raise Bundler::ConnectionPool::Error, 'no connections are checked out' if
17
- stack.empty?
28
+ raise Bundler::ConnectionPool::Error, 'no connections are checked out' if
29
+ stack.empty?
18
30
 
19
- conn = stack.pop
31
+ conn = stack.pop
20
32
 
21
- if stack.empty?
22
- @available.push conn, connection_args: net_http_args
33
+ if stack.empty?
34
+ @available.push conn, connection_args: net_http_args
23
35
 
24
- Thread.current[@key].delete(net_http_args)
25
- Thread.current[@key] = nil if Thread.current[@key].empty?
36
+ Thread.current[@key].delete(net_http_args)
37
+ Thread.current[@key] = nil if Thread.current[@key].empty?
38
+ end
26
39
  end
27
-
28
40
  nil
29
41
  end
30
42
 
@@ -174,7 +174,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
174
174
  ##
175
175
  # The version of Bundler::Persistent::Net::HTTP::Persistent you are using
176
176
 
177
- VERSION = '4.0.1'
177
+ VERSION = '4.0.2'
178
178
 
179
179
  ##
180
180
  # Error class for errors raised by Bundler::Persistent::Net::HTTP::Persistent. Various
@@ -43,7 +43,8 @@ class Bundler::Thor
43
43
  # Boolean:: true if it is identical, false otherwise.
44
44
  #
45
45
  def identical?
46
- exists? && File.binread(destination) == render
46
+ # binread uses ASCII-8BIT, so to avoid false negatives, the string must use the same
47
+ exists? && File.binread(destination) == String.new(render).force_encoding("ASCII-8BIT")
47
48
  end
48
49
 
49
50
  # Holds the content to be added to the file.
@@ -60,7 +61,7 @@ class Bundler::Thor
60
61
  invoke_with_conflict_check do
61
62
  require "fileutils"
62
63
  FileUtils.mkdir_p(File.dirname(destination))
63
- File.open(destination, "wb") { |f| f.write render }
64
+ File.open(destination, "wb", config[:perm]) { |f| f.write render }
64
65
  end
65
66
  given_destination
66
67
  end
@@ -58,7 +58,7 @@ class Bundler::Thor
58
58
  def initialize(base, source, destination = nil, config = {}, &block)
59
59
  @source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)
60
60
  @block = block
61
- super(base, destination, {:recursive => true}.merge(config))
61
+ super(base, destination, {recursive: true}.merge(config))
62
62
  end
63
63
 
64
64
  def invoke!
@@ -33,7 +33,7 @@ class Bundler::Thor
33
33
  #
34
34
  def initialize(base, destination, config = {})
35
35
  @base = base
36
- @config = {:verbose => true}.merge(config)
36
+ @config = {verbose: true}.merge(config)
37
37
  self.destination = destination
38
38
  end
39
39
 
@@ -66,12 +66,15 @@ class Bundler::Thor
66
66
  # ==== Parameters
67
67
  # source<String>:: the address of the given content.
68
68
  # destination<String>:: the relative path to the destination root.
69
- # config<Hash>:: give :verbose => false to not log the status.
69
+ # config<Hash>:: give :verbose => false to not log the status, and
70
+ # :http_headers => <Hash> to add headers to an http request.
70
71
  #
71
72
  # ==== Examples
72
73
  #
73
74
  # get "http://gist.github.com/103208", "doc/README"
74
75
  #
76
+ # get "http://gist.github.com/103208", "doc/README", :http_headers => {"Content-Type" => "application/json"}
77
+ #
75
78
  # get "http://gist.github.com/103208" do |content|
76
79
  # content.split("\n").first
77
80
  # end
@@ -82,10 +85,10 @@ class Bundler::Thor
82
85
 
83
86
  render = if source =~ %r{^https?\://}
84
87
  require "open-uri"
85
- URI.send(:open, source) { |input| input.binmode.read }
88
+ URI.send(:open, source, config.fetch(:http_headers, {})) { |input| input.binmode.read }
86
89
  else
87
90
  source = File.expand_path(find_in_source_paths(source.to_s))
88
- open(source) { |input| input.binmode.read }
91
+ File.open(source) { |input| input.binmode.read }
89
92
  end
90
93
 
91
94
  destination ||= if block_given?
@@ -120,12 +123,7 @@ class Bundler::Thor
120
123
  context = config.delete(:context) || instance_eval("binding")
121
124
 
122
125
  create_file destination, nil, config do
123
- match = ERB.version.match(/(\d+\.\d+\.\d+)/)
124
- capturable_erb = if match && match[1] >= "2.2.0" # Ruby 2.6+
125
- CapturableERB.new(::File.binread(source), :trim_mode => "-", :eoutvar => "@output_buffer")
126
- else
127
- CapturableERB.new(::File.binread(source), nil, "-", "@output_buffer")
128
- end
126
+ capturable_erb = CapturableERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer")
129
127
  content = capturable_erb.tap do |erb|
130
128
  erb.filename = source
131
129
  end.result(context)
@@ -252,7 +250,7 @@ class Bundler::Thor
252
250
  # flag<Regexp|String>:: the regexp or string to be replaced
253
251
  # replacement<String>:: the replacement, can be also given as a block
254
252
  # config<Hash>:: give :verbose => false to not log the status, and
255
- # :force => true, to force the replacement regardles of runner behavior.
253
+ # :force => true, to force the replacement regardless of runner behavior.
256
254
  #
257
255
  # ==== Example
258
256
  #