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
@@ -7,72 +7,24 @@ require_relative "rubygems_ext"
7
7
  module Bundler
8
8
  class Dependency < Gem::Dependency
9
9
  attr_reader :autorequire
10
- attr_reader :groups, :platforms, :gemfile, :git, :branch
10
+ attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :force_ruby_platform
11
11
 
12
+ ALL_RUBY_VERSIONS = ((18..27).to_a + (30..31).to_a).freeze
12
13
  PLATFORM_MAP = {
13
- :ruby => Gem::Platform::RUBY,
14
- :ruby_18 => Gem::Platform::RUBY,
15
- :ruby_19 => Gem::Platform::RUBY,
16
- :ruby_20 => Gem::Platform::RUBY,
17
- :ruby_21 => Gem::Platform::RUBY,
18
- :ruby_22 => Gem::Platform::RUBY,
19
- :ruby_23 => Gem::Platform::RUBY,
20
- :ruby_24 => Gem::Platform::RUBY,
21
- :ruby_25 => Gem::Platform::RUBY,
22
- :ruby_26 => Gem::Platform::RUBY,
23
- :mri => Gem::Platform::RUBY,
24
- :mri_18 => Gem::Platform::RUBY,
25
- :mri_19 => Gem::Platform::RUBY,
26
- :mri_20 => Gem::Platform::RUBY,
27
- :mri_21 => Gem::Platform::RUBY,
28
- :mri_22 => Gem::Platform::RUBY,
29
- :mri_23 => Gem::Platform::RUBY,
30
- :mri_24 => Gem::Platform::RUBY,
31
- :mri_25 => Gem::Platform::RUBY,
32
- :mri_26 => Gem::Platform::RUBY,
33
- :rbx => Gem::Platform::RUBY,
34
- :truffleruby => Gem::Platform::RUBY,
35
- :jruby => Gem::Platform::JAVA,
36
- :jruby_18 => Gem::Platform::JAVA,
37
- :jruby_19 => Gem::Platform::JAVA,
38
- :mswin => Gem::Platform::MSWIN,
39
- :mswin_18 => Gem::Platform::MSWIN,
40
- :mswin_19 => Gem::Platform::MSWIN,
41
- :mswin_20 => Gem::Platform::MSWIN,
42
- :mswin_21 => Gem::Platform::MSWIN,
43
- :mswin_22 => Gem::Platform::MSWIN,
44
- :mswin_23 => Gem::Platform::MSWIN,
45
- :mswin_24 => Gem::Platform::MSWIN,
46
- :mswin_25 => Gem::Platform::MSWIN,
47
- :mswin_26 => Gem::Platform::MSWIN,
48
- :mswin64 => Gem::Platform::MSWIN64,
49
- :mswin64_19 => Gem::Platform::MSWIN64,
50
- :mswin64_20 => Gem::Platform::MSWIN64,
51
- :mswin64_21 => Gem::Platform::MSWIN64,
52
- :mswin64_22 => Gem::Platform::MSWIN64,
53
- :mswin64_23 => Gem::Platform::MSWIN64,
54
- :mswin64_24 => Gem::Platform::MSWIN64,
55
- :mswin64_25 => Gem::Platform::MSWIN64,
56
- :mswin64_26 => Gem::Platform::MSWIN64,
57
- :mingw => Gem::Platform::MINGW,
58
- :mingw_18 => Gem::Platform::MINGW,
59
- :mingw_19 => Gem::Platform::MINGW,
60
- :mingw_20 => Gem::Platform::MINGW,
61
- :mingw_21 => Gem::Platform::MINGW,
62
- :mingw_22 => Gem::Platform::MINGW,
63
- :mingw_23 => Gem::Platform::MINGW,
64
- :mingw_24 => Gem::Platform::MINGW,
65
- :mingw_25 => Gem::Platform::MINGW,
66
- :mingw_26 => Gem::Platform::MINGW,
67
- :x64_mingw => Gem::Platform::X64_MINGW,
68
- :x64_mingw_20 => Gem::Platform::X64_MINGW,
69
- :x64_mingw_21 => Gem::Platform::X64_MINGW,
70
- :x64_mingw_22 => Gem::Platform::X64_MINGW,
71
- :x64_mingw_23 => Gem::Platform::X64_MINGW,
72
- :x64_mingw_24 => Gem::Platform::X64_MINGW,
73
- :x64_mingw_25 => Gem::Platform::X64_MINGW,
74
- :x64_mingw_26 => Gem::Platform::X64_MINGW,
75
- }.freeze
14
+ :ruby => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
15
+ :mri => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
16
+ :rbx => [Gem::Platform::RUBY],
17
+ :truffleruby => [Gem::Platform::RUBY],
18
+ :jruby => [Gem::Platform::JAVA, [18, 19]],
19
+ :windows => [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS],
20
+ :mswin => [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS],
21
+ :mswin64 => [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]],
22
+ :mingw => [Gem::Platform::MINGW, ALL_RUBY_VERSIONS],
23
+ :x64_mingw => [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]],
24
+ }.each_with_object({}) do |(platform, spec), hash|
25
+ hash[platform] = spec[0]
26
+ spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }
27
+ end.freeze
76
28
 
77
29
  def initialize(name, version, options = {}, &blk)
78
30
  type = options["type"] || :runtime
@@ -81,12 +33,16 @@ module Bundler
81
33
  @autorequire = nil
82
34
  @groups = Array(options["group"] || :default).map(&:to_sym)
83
35
  @source = options["source"]
36
+ @path = options["path"]
84
37
  @git = options["git"]
38
+ @github = options["github"]
85
39
  @branch = options["branch"]
40
+ @ref = options["ref"]
86
41
  @platforms = Array(options["platforms"])
87
42
  @env = options["env"]
88
43
  @should_include = options.fetch("should_include", true)
89
44
  @gemfile = options["gemfile"]
45
+ @force_ruby_platform = options["force_ruby_platform"]
90
46
 
91
47
  @autorequire = Array(options["require"] || []) if options.key?("require")
92
48
  end
@@ -96,15 +52,11 @@ module Bundler
96
52
  def gem_platforms(valid_platforms)
97
53
  return valid_platforms if @platforms.empty?
98
54
 
99
- valid_generic_platforms = valid_platforms.map {|p| [p, GemHelpers.generic(p)] }.to_h
100
- @gem_platforms ||= expanded_platforms.compact.uniq
101
-
102
- filtered_generic_platforms = valid_generic_platforms.values & @gem_platforms
103
- valid_generic_platforms.select {|_, v| filtered_generic_platforms.include?(v) }.keys
55
+ valid_platforms.select {|p| expanded_platforms.include?(GemHelpers.generic(p)) }
104
56
  end
105
57
 
106
58
  def expanded_platforms
107
- @platforms.map {|pl| PLATFORM_MAP[pl] }
59
+ @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.flatten.uniq
108
60
  end
109
61
 
110
62
  def should_include?
@@ -132,7 +84,7 @@ module Bundler
132
84
  def to_lock
133
85
  out = super
134
86
  out << "!" if source
135
- out << "\n"
87
+ out
136
88
  end
137
89
 
138
90
  def specific?
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This code was extracted from https://github.com/Solistra/ruby-digest which is under public domain
4
+ module Bundler
5
+ module Digest
6
+ # The initial constant values for the 32-bit constant words A, B, C, D, and
7
+ # E, respectively.
8
+ SHA1_WORDS = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0].freeze
9
+
10
+ # The 8-bit field used for bitwise `AND` masking. Defaults to `0xFFFFFFFF`.
11
+ SHA1_MASK = 0xFFFFFFFF
12
+
13
+ class << self
14
+ def sha1(string)
15
+ unless string.is_a?(String)
16
+ raise TypeError, "can't convert #{string.class.inspect} into String"
17
+ end
18
+
19
+ buffer = string.b
20
+
21
+ words = SHA1_WORDS.dup
22
+ generate_split_buffer(buffer) do |chunk|
23
+ w = []
24
+ chunk.each_slice(4) do |a, b, c, d|
25
+ w << (((a << 8 | b) << 8 | c) << 8 | d)
26
+ end
27
+ a, b, c, d, e = *words
28
+ (16..79).each do |i|
29
+ w[i] = SHA1_MASK & rotate((w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]), 1)
30
+ end
31
+ 0.upto(79) do |i|
32
+ case i
33
+ when 0..19
34
+ f = ((b & c) | (~b & d))
35
+ k = 0x5A827999
36
+ when 20..39
37
+ f = (b ^ c ^ d)
38
+ k = 0x6ED9EBA1
39
+ when 40..59
40
+ f = ((b & c) | (b & d) | (c & d))
41
+ k = 0x8F1BBCDC
42
+ when 60..79
43
+ f = (b ^ c ^ d)
44
+ k = 0xCA62C1D6
45
+ end
46
+ t = SHA1_MASK & (SHA1_MASK & rotate(a, 5) + f + e + k + w[i])
47
+ a, b, c, d, e = t, a, SHA1_MASK & rotate(b, 30), c, d # rubocop:disable Style/ParallelAssignment
48
+ end
49
+ mutated = [a, b, c, d, e]
50
+ words.map!.with_index {|word, index| SHA1_MASK & (word + mutated[index]) }
51
+ end
52
+
53
+ words.pack("N*").unpack("H*").first
54
+ end
55
+
56
+ private
57
+
58
+ def generate_split_buffer(string, &block)
59
+ size = string.bytesize * 8
60
+ buffer = string.bytes << 128
61
+ buffer << 0 while buffer.size % 64 != 56
62
+ buffer.concat([size].pack("Q>").bytes)
63
+ buffer.each_slice(64, &block)
64
+ end
65
+
66
+ def rotate(value, spaces)
67
+ value << spaces | value >> (32 - spaces)
68
+ end
69
+ end
70
+ end
71
+ end
data/lib/bundler/dsl.rb CHANGED
@@ -16,7 +16,9 @@ module Bundler
16
16
  VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
17
17
 
18
18
  VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
19
- platform platforms type source install_if gemfile].freeze
19
+ platform platforms type source install_if gemfile force_ruby_platform].freeze
20
+
21
+ GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}.freeze
20
22
 
21
23
  attr_reader :gemspecs
22
24
  attr_accessor :dependencies
@@ -44,7 +46,7 @@ module Bundler
44
46
  @gemfile = expanded_gemfile_path
45
47
  @gemfiles << expanded_gemfile_path
46
48
  contents ||= Bundler.read_file(@gemfile.to_s)
47
- instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
49
+ instance_eval(contents.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
48
50
  rescue Exception => e # rubocop:disable Lint/RescueException
49
51
  message = "There was an error " \
50
52
  "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
@@ -65,7 +67,6 @@ module Bundler
65
67
 
66
68
  gemspecs = Gem::Util.glob_files_in_dir("{,*}.gemspec", expanded_path).map {|g| Bundler.load_gemspec(g) }.compact
67
69
  gemspecs.reject! {|s| s.name != name } if name
68
- Index.sort_specs(gemspecs)
69
70
  specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] }
70
71
 
71
72
  case specs_by_name_and_version.size
@@ -122,19 +123,17 @@ module Bundler
122
123
  raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
123
124
  "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \
124
125
  "#{update_prompt}"
126
+ elsif current.source != dep.source
127
+ return if dep.type == :development
128
+ raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
129
+ "You specified that #{dep.name} (#{dep.requirement}) should come from " \
130
+ "#{current.source || "an unspecified source"} and #{dep.source}\n"
125
131
  else
126
132
  Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
127
133
  "You should probably keep only one of them.\n" \
128
134
  "Remove any duplicate entries and specify the gem only once.\n" \
129
135
  "While it's not a problem now, it could cause errors if you change the version of one of them later."
130
136
  end
131
-
132
- if current.source != dep.source
133
- return if dep.type == :development
134
- raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
135
- "You specified that #{dep.name} (#{dep.requirement}) should come from " \
136
- "#{current.source || "an unspecified source"} and #{dep.source}\n"
137
- end
138
137
  end
139
138
  end
140
139
 
@@ -275,26 +274,24 @@ module Bundler
275
274
 
276
275
  def add_git_sources
277
276
  git_source(:github) do |repo_name|
278
- warn_deprecated_git_source(:github, <<-'RUBY'.strip, 'Change any "reponame" :github sources to "username/reponame".')
279
- "https://github.com/#{repo_name}.git"
280
- RUBY
281
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
282
- "https://github.com/#{repo_name}.git"
277
+ if repo_name =~ GITHUB_PULL_REQUEST_URL
278
+ {
279
+ "git" => "https://github.com/#{$1}.git",
280
+ "branch" => "refs/pull/#{$2}/head",
281
+ "ref" => nil,
282
+ "tag" => nil,
283
+ }
284
+ else
285
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
286
+ "https://github.com/#{repo_name}.git"
287
+ end
283
288
  end
284
289
 
285
290
  git_source(:gist) do |repo_name|
286
- warn_deprecated_git_source(:gist, '"https://gist.github.com/#{repo_name}.git"')
287
-
288
291
  "https://gist.github.com/#{repo_name}.git"
289
292
  end
290
293
 
291
294
  git_source(:bitbucket) do |repo_name|
292
- warn_deprecated_git_source(:bitbucket, <<-'RUBY'.strip)
293
- user_name, repo_name = repo_name.split("/")
294
- repo_name ||= user_name
295
- "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
296
- RUBY
297
-
298
295
  user_name, repo_name = repo_name.split("/")
299
296
  repo_name ||= user_name
300
297
  "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
@@ -365,7 +362,11 @@ repo_name ||= user_name
365
362
 
366
363
  git_name = (git_names & opts.keys).last
367
364
  if @git_sources[git_name]
368
- opts["git"] = @git_sources[git_name].call(opts[git_name])
365
+ git_opts = @git_sources[git_name].call(opts[git_name])
366
+ git_opts = { "git" => git_opts } if git_opts.is_a?(String)
367
+ opts.merge!(git_opts) do |key, _gemfile_value, _git_source_value|
368
+ raise GemfileError, %(The :#{key} option can't be used with `#{git_name}: #{opts[git_name].inspect}`)
369
+ end
369
370
  end
370
371
 
371
372
  %w[git path].each do |type|
@@ -463,34 +464,18 @@ repo_name ||= user_name
463
464
 
464
465
  def multiple_global_source_warning
465
466
  if Bundler.feature_flag.bundler_3_mode?
466
- msg = "This Gemfile contains multiple primary sources. " \
467
+ msg = "This Gemfile contains multiple global sources. " \
467
468
  "Each source after the first must include a block to indicate which gems " \
468
469
  "should come from that source"
469
470
  raise GemfileEvalError, msg
470
471
  else
471
- Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \
472
+ Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple global sources. " \
472
473
  "Using `source` more than once without a block is a security risk, and " \
473
474
  "may result in installing unexpected gems. To resolve this warning, use " \
474
475
  "a block to indicate which gems should come from the secondary source."
475
476
  end
476
477
  end
477
478
 
478
- def warn_deprecated_git_source(name, replacement, additional_message = nil)
479
- additional_message &&= " #{additional_message}"
480
- replacement = if replacement.count("\n").zero?
481
- "{|repo_name| #{replacement} }"
482
- else
483
- "do |repo_name|\n#{replacement.to_s.gsub(/^/, " ")}\n end"
484
- end
485
-
486
- Bundler::SharedHelpers.major_deprecation 3, <<-EOS
487
- The :#{name} git source is deprecated, and will be removed in the future.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work:
488
-
489
- git_source(:#{name}) #{replacement}
490
-
491
- EOS
492
- end
493
-
494
479
  class DSLError < GemfileError
495
480
  # @return [String] the description that should be presented to the user.
496
481
  #
@@ -525,9 +510,7 @@ The :#{name} git source is deprecated, and will be removed in the future.#{addit
525
510
  # be raised.
526
511
  #
527
512
  def contents
528
- @contents ||= begin
529
- dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
530
- end
513
+ @contents ||= dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
531
514
  end
532
515
 
533
516
  # The message of the exception reports the content of podspec for the
@@ -3,17 +3,17 @@
3
3
  module Bundler
4
4
  # used for Creating Specifications from the Gemcutter Endpoint
5
5
  class EndpointSpecification < Gem::Specification
6
- ILLFORMED_MESSAGE = 'Ill-formed requirement ["#<YAML::Syck::DefaultKey'.freeze
7
- include MatchPlatform
6
+ include MatchRemoteMetadata
8
7
 
9
- attr_reader :name, :version, :platform, :required_rubygems_version, :required_ruby_version, :checksum
8
+ attr_reader :name, :version, :platform, :checksum
10
9
  attr_accessor :source, :remote, :dependencies
11
10
 
12
- def initialize(name, version, platform, dependencies, metadata = nil)
11
+ def initialize(name, version, platform, spec_fetcher, dependencies, metadata = nil)
13
12
  super()
14
13
  @name = name
15
14
  @version = Gem::Version.create version
16
- @platform = platform
15
+ @platform = Gem::Platform.new(platform)
16
+ @spec_fetcher = spec_fetcher
17
17
  @dependencies = dependencies.map {|dep, reqs| build_dependency(dep, reqs) }
18
18
 
19
19
  @loaded_from = nil
@@ -26,6 +26,10 @@ module Bundler
26
26
  @platform
27
27
  end
28
28
 
29
+ def identifier
30
+ @__identifier ||= [name, version, platform.to_s]
31
+ end
32
+
29
33
  # needed for standalone, load required_paths from local gemspec
30
34
  # after the gem is installed
31
35
  def require_paths
@@ -106,12 +110,21 @@ module Bundler
106
110
 
107
111
  private
108
112
 
113
+ def _remote_specification
114
+ @_remote_specification ||= @spec_fetcher.fetch_spec([@name, @version, @platform])
115
+ end
116
+
109
117
  def local_specification_path
110
118
  "#{base_dir}/specifications/#{full_name}.gemspec"
111
119
  end
112
120
 
113
121
  def parse_metadata(data)
114
- return unless data
122
+ unless data
123
+ @required_ruby_version = nil
124
+ @required_rubygems_version = nil
125
+ return
126
+ end
127
+
115
128
  data.each do |k, v|
116
129
  next unless v
117
130
  case k.to_s
@@ -129,13 +142,6 @@ module Bundler
129
142
 
130
143
  def build_dependency(name, requirements)
131
144
  Gem::Dependency.new(name, requirements)
132
- rescue ArgumentError => e
133
- raise unless e.message.include?(ILLFORMED_MESSAGE)
134
- puts # we shouldn't print the error message on the "fetching info" status line
135
- raise GemspecError,
136
- "Unfortunately, the gem #{name} (#{version}) has an invalid " \
137
- "gemspec.\nPlease ask the gem author to yank the bad version to fix " \
138
- "this issue. For more information, see http://bit.ly/syck-defaultkey."
139
145
  end
140
146
  end
141
147
  end
data/lib/bundler/env.rb CHANGED
@@ -71,7 +71,7 @@ module Bundler
71
71
  def self.ruby_version
72
72
  str = String.new(RUBY_VERSION)
73
73
  str << "p#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
74
- str << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{RUBY_PLATFORM}]"
74
+ str << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{Gem::Platform.local}]"
75
75
  end
76
76
 
77
77
  def self.git_version
@@ -38,7 +38,10 @@ module Bundler
38
38
 
39
39
  # Replaces `ENV` with the bundler environment variables backed up
40
40
  def replace_with_backup
41
- ENV.replace(backup) unless Gem.win_platform?
41
+ unless Gem.win_platform?
42
+ ENV.replace(backup)
43
+ return
44
+ end
42
45
 
43
46
  # Fallback logic for Windows below to workaround
44
47
  # https://bugs.ruby-lang.org/issues/16798. Can be dropped once all
@@ -41,12 +41,14 @@ module Bundler
41
41
  class GemspecError < BundlerError; status_code(14); end
42
42
  class InvalidOption < BundlerError; status_code(15); end
43
43
  class ProductionError < BundlerError; status_code(16); end
44
+
44
45
  class HTTPError < BundlerError
45
46
  status_code(17)
46
47
  def filter_uri(uri)
47
48
  URICredentialsFilter.credential_filtered_uri(uri)
48
49
  end
49
50
  end
51
+
50
52
  class RubyVersionMismatch < BundlerError; status_code(18); end
51
53
  class SecurityError < BundlerError; status_code(19); end
52
54
  class LockfileError < BundlerError; status_code(20); end
@@ -75,10 +77,22 @@ module Bundler
75
77
  end
76
78
  end
77
79
 
80
+ def permission_type
81
+ case @permission_type
82
+ when :create
83
+ "executable permissions for all parent directories and write permissions for `#{parent_folder}`"
84
+ else
85
+ "#{@permission_type} permissions for that path"
86
+ end
87
+ end
88
+
89
+ def parent_folder
90
+ File.dirname(@path)
91
+ end
92
+
78
93
  def message
79
94
  "There was an error while trying to #{action} `#{@path}`. " \
80
- "It is likely that you need to grant #{@permission_type} permissions " \
81
- "for that path."
95
+ "It is likely that you need to grant #{permission_type}."
82
96
  end
83
97
 
84
98
  status_code(23)
@@ -156,4 +170,16 @@ module Bundler
156
170
 
157
171
  status_code(32)
158
172
  end
173
+
174
+ class DirectoryRemovalError < BundlerError
175
+ def initialize(orig_exception, msg)
176
+ full_message = "#{msg}.\n" \
177
+ "The underlying error was #{orig_exception.class}: #{orig_exception.message}, with backtrace:\n" \
178
+ " #{orig_exception.backtrace.join("\n ")}\n\n" \
179
+ "Bundler Error Backtrace:"
180
+ super(full_message)
181
+ end
182
+
183
+ status_code(36)
184
+ end
159
185
  end
@@ -39,7 +39,6 @@ module Bundler
39
39
  settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
40
40
  settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
41
41
  settings_flag(:update_requires_all_flag) { bundler_4_mode? }
42
- settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_3_mode? }
43
42
 
44
43
  settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
45
44
 
@@ -19,14 +19,12 @@ module Bundler
19
19
  end
20
20
 
21
21
  def fetch_uri
22
- @fetch_uri ||= begin
23
- if remote_uri.host == "rubygems.org"
24
- uri = remote_uri.dup
25
- uri.host = "index.rubygems.org"
26
- uri
27
- else
28
- remote_uri
29
- end
22
+ @fetch_uri ||= if remote_uri.host == "rubygems.org"
23
+ uri = remote_uri.dup
24
+ uri.host = "index.rubygems.org"
25
+ uri
26
+ else
27
+ remote_uri
30
28
  end
31
29
  end
32
30
 
@@ -57,22 +57,17 @@ module Bundler
57
57
  gem_info
58
58
  end
59
59
 
60
- def fetch_spec(spec)
61
- spec -= [nil, "ruby", ""]
62
- contents = compact_index_client.spec(*spec)
63
- return nil if contents.nil?
64
- contents.unshift(spec.first)
65
- contents[3].map! {|d| Gem::Dependency.new(*d) }
66
- EndpointSpecification.new(*contents)
67
- end
68
- compact_index_request :fetch_spec
69
-
70
60
  def available?
71
- return nil unless SharedHelpers.md5_available?
72
- user_home = Bundler.user_home
73
- return nil unless user_home.directory? && user_home.writable?
61
+ unless SharedHelpers.md5_available?
62
+ Bundler.ui.debug("FIPS mode is enabled, bundler can't use the CompactIndex API")
63
+ return nil
64
+ end
65
+ if fetch_uri.scheme == "file"
66
+ Bundler.ui.debug("Using a local server, bundler won't use the CompactIndex API")
67
+ return false
68
+ end
74
69
  # Read info file checksums out of /versions, so we can know if gems are up to date
75
- fetch_uri.scheme != "file" && compact_index_client.update_and_parse_checksums!
70
+ compact_index_client.update_and_parse_checksums!
76
71
  rescue CompactIndexClient::Updater::MisMatchedChecksumError => e
77
72
  Bundler.ui.debug(e.message)
78
73
  nil
@@ -21,32 +21,6 @@ module Bundler
21
21
  raise HTTPError, "Could not fetch specs from #{display_uri} due to underlying error <#{e.message}>"
22
22
  end
23
23
  end
24
-
25
- def fetch_spec(spec)
26
- spec -= [nil, "ruby", ""]
27
- spec_file_name = "#{spec.join "-"}.gemspec"
28
-
29
- uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
30
- if uri.scheme == "file"
31
- path = Bundler.rubygems.correct_for_windows_path(uri.path)
32
- Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
33
- elsif cached_spec_path = gemspec_cached_path(spec_file_name)
34
- Bundler.load_gemspec(cached_spec_path)
35
- else
36
- Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
37
- end
38
- rescue MarshalError
39
- raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
40
- "Your network or your gem server is probably having issues right now."
41
- end
42
-
43
- private
44
-
45
- # cached gem specification path, if one exists
46
- def gemspec_cached_path(spec_file_name)
47
- paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
48
- paths.find {|path| File.file? path }
49
- end
50
24
  end
51
25
  end
52
26
  end