bundler 2.1.4 → 2.2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2017 -1430
  3. data/README.md +7 -9
  4. data/bundler.gemspec +5 -6
  5. data/exe/bundle +3 -0
  6. data/lib/bundler/build_metadata.rb +3 -11
  7. data/lib/bundler/cli/add.rb +1 -1
  8. data/lib/bundler/cli/binstubs.rb +6 -2
  9. data/lib/bundler/cli/cache.rb +3 -8
  10. data/lib/bundler/cli/check.rb +4 -2
  11. data/lib/bundler/cli/clean.rb +1 -1
  12. data/lib/bundler/cli/common.rb +29 -2
  13. data/lib/bundler/cli/console.rb +1 -1
  14. data/lib/bundler/cli/doctor.rb +16 -5
  15. data/lib/bundler/cli/exec.rb +5 -10
  16. data/lib/bundler/cli/fund.rb +36 -0
  17. data/lib/bundler/cli/gem.rb +209 -28
  18. data/lib/bundler/cli/info.rb +28 -5
  19. data/lib/bundler/cli/init.rb +2 -2
  20. data/lib/bundler/cli/inject.rb +1 -1
  21. data/lib/bundler/cli/install.rb +22 -34
  22. data/lib/bundler/cli/issue.rb +5 -4
  23. data/lib/bundler/cli/list.rb +19 -11
  24. data/lib/bundler/cli/lock.rb +5 -1
  25. data/lib/bundler/cli/open.rb +1 -2
  26. data/lib/bundler/cli/outdated.rb +95 -75
  27. data/lib/bundler/cli/plugin.rb +10 -0
  28. data/lib/bundler/cli/pristine.rb +5 -0
  29. data/lib/bundler/cli/remove.rb +1 -2
  30. data/lib/bundler/cli/show.rb +1 -1
  31. data/lib/bundler/cli/update.rb +14 -7
  32. data/lib/bundler/cli.rb +89 -66
  33. data/lib/bundler/compact_index_client/cache.rb +6 -14
  34. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  35. data/lib/bundler/compact_index_client/updater.rb +13 -22
  36. data/lib/bundler/compact_index_client.rb +3 -3
  37. data/lib/bundler/current_ruby.rb +5 -4
  38. data/lib/bundler/definition.rb +193 -363
  39. data/lib/bundler/dep_proxy.rb +16 -9
  40. data/lib/bundler/dependency.rb +3 -10
  41. data/lib/bundler/digest.rb +71 -0
  42. data/lib/bundler/dsl.rb +71 -47
  43. data/lib/bundler/endpoint_specification.rb +1 -1
  44. data/lib/bundler/env.rb +1 -1
  45. data/lib/bundler/environment_preserver.rb +29 -2
  46. data/lib/bundler/errors.rb +20 -3
  47. data/lib/bundler/feature_flag.rb +0 -8
  48. data/lib/bundler/fetcher/base.rb +1 -1
  49. data/lib/bundler/fetcher/compact_index.rb +2 -2
  50. data/lib/bundler/fetcher/downloader.rb +10 -7
  51. data/lib/bundler/fetcher/index.rb +3 -5
  52. data/lib/bundler/fetcher.rb +7 -5
  53. data/lib/bundler/friendly_errors.rb +25 -43
  54. data/lib/bundler/gem_helper.rb +53 -31
  55. data/lib/bundler/gem_helpers.rb +36 -25
  56. data/lib/bundler/gem_version_promoter.rb +4 -4
  57. data/lib/bundler/graph.rb +1 -1
  58. data/lib/bundler/index.rb +9 -9
  59. data/lib/bundler/injector.rb +23 -5
  60. data/lib/bundler/inline.rb +3 -2
  61. data/lib/bundler/installer/gem_installer.rb +6 -19
  62. data/lib/bundler/installer/parallel_installer.rb +46 -25
  63. data/lib/bundler/installer/standalone.rb +30 -10
  64. data/lib/bundler/installer.rb +36 -56
  65. data/lib/bundler/lazy_specification.rb +62 -26
  66. data/lib/bundler/lockfile_generator.rb +1 -1
  67. data/lib/bundler/lockfile_parser.rb +8 -34
  68. data/lib/bundler/man/.document +1 -0
  69. data/{man → lib/bundler/man}/bundle-add.1 +1 -1
  70. data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +0 -0
  71. data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  72. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  73. data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
  74. data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
  75. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  76. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  77. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  78. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  79. data/{man → lib/bundler/man}/bundle-config.1 +40 -41
  80. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +50 -53
  81. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  82. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  83. data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
  84. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
  85. data/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  86. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  87. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  88. data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  89. data/{man → lib/bundler/man}/bundle-init.1 +1 -1
  90. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  91. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  92. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
  93. data/{man → lib/bundler/man}/bundle-install.1 +30 -3
  94. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +25 -3
  95. data/{man → lib/bundler/man}/bundle-list.1 +7 -7
  96. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  97. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  98. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  99. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  100. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  101. data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
  102. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +0 -0
  103. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  104. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
  105. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  106. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  107. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  108. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  109. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  110. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  111. data/{man → lib/bundler/man}/bundle-update.1 +4 -4
  112. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +3 -3
  113. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  114. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
  115. data/{man → lib/bundler/man}/bundle.1 +1 -1
  116. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
  117. data/{man → lib/bundler/man}/gemfile.5 +30 -4
  118. data/{man → lib/bundler/man}/gemfile.5.ronn +12 -4
  119. data/{man → lib/bundler/man}/index.txt +0 -0
  120. data/lib/bundler/mirror.rb +2 -2
  121. data/lib/bundler/plugin/api/source.rb +23 -1
  122. data/lib/bundler/plugin/dsl.rb +1 -1
  123. data/lib/bundler/plugin/index.rb +13 -1
  124. data/lib/bundler/plugin/installer/rubygems.rb +1 -1
  125. data/lib/bundler/plugin/installer.rb +11 -11
  126. data/lib/bundler/plugin/source_list.rb +5 -1
  127. data/lib/bundler/plugin.rb +56 -11
  128. data/lib/bundler/psyched_yaml.rb +0 -15
  129. data/lib/bundler/remote_specification.rb +5 -2
  130. data/lib/bundler/resolver/spec_group.rb +56 -53
  131. data/lib/bundler/resolver.rb +94 -128
  132. data/lib/bundler/retry.rb +2 -2
  133. data/lib/bundler/ruby_version.rb +1 -1
  134. data/lib/bundler/rubygems_ext.rb +96 -16
  135. data/lib/bundler/rubygems_gem_installer.rb +69 -8
  136. data/lib/bundler/rubygems_integration.rb +57 -72
  137. data/lib/bundler/runtime.rb +22 -25
  138. data/lib/bundler/settings.rb +142 -64
  139. data/lib/bundler/setup.rb +2 -2
  140. data/lib/bundler/shared_helpers.rb +5 -13
  141. data/lib/bundler/similarity_detector.rb +1 -1
  142. data/lib/bundler/source/git/git_proxy.rb +88 -84
  143. data/lib/bundler/source/git.rb +43 -23
  144. data/lib/bundler/source/metadata.rb +0 -4
  145. data/lib/bundler/source/path/installer.rb +10 -10
  146. data/lib/bundler/source/path.rb +10 -4
  147. data/lib/bundler/source/rubygems/remote.rb +1 -1
  148. data/lib/bundler/source/rubygems.rb +126 -116
  149. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  150. data/lib/bundler/source.rb +22 -1
  151. data/lib/bundler/source_list.rb +101 -63
  152. data/lib/bundler/source_map.rb +58 -0
  153. data/lib/bundler/spec_set.rb +26 -41
  154. data/lib/bundler/stub_specification.rb +25 -7
  155. data/lib/bundler/templates/Executable.bundler +6 -6
  156. data/lib/bundler/templates/Gemfile +1 -1
  157. data/lib/bundler/templates/gems.rb +1 -1
  158. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  159. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  160. data/lib/bundler/templates/newgem/Gemfile.tt +12 -1
  161. data/lib/bundler/templates/newgem/README.md.tt +6 -5
  162. data/lib/bundler/templates/newgem/Rakefile.tt +23 -5
  163. data/lib/bundler/templates/newgem/bin/console.tt +1 -0
  164. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  165. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  166. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  167. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  168. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  169. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  170. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
  171. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  172. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  173. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  174. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  175. data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  176. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
  177. data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  178. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  179. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  180. data/lib/bundler/ui/shell.rb +5 -5
  181. data/lib/bundler/uri_credentials_filter.rb +3 -1
  182. data/lib/bundler/vendor/.document +1 -0
  183. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  184. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  185. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  186. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  187. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  188. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  189. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  190. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  191. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  192. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  193. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +36 -4
  194. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +3 -3
  195. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  196. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  197. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  198. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  199. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  200. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  201. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  202. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  203. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
  204. data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
  205. data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  206. data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
  207. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  208. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
  209. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
  210. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  211. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  212. data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  213. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  214. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  215. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  216. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  217. data/lib/bundler/vendored_persistent.rb +0 -7
  218. data/lib/bundler/vendored_tmpdir.rb +4 -0
  219. data/lib/bundler/vendored_tsort.rb +4 -0
  220. data/lib/bundler/version.rb +1 -1
  221. data/lib/bundler/worker.rb +20 -5
  222. data/lib/bundler/yaml_serializer.rb +1 -1
  223. data/lib/bundler.rb +52 -37
  224. metadata +90 -89
  225. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  226. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  227. data/man/bundle-add.1.txt +0 -58
  228. data/man/bundle-binstubs.1.txt +0 -48
  229. data/man/bundle-cache.1.txt +0 -78
  230. data/man/bundle-check.1.txt +0 -33
  231. data/man/bundle-clean.1.txt +0 -26
  232. data/man/bundle-config.1.txt +0 -528
  233. data/man/bundle-doctor.1.txt +0 -44
  234. data/man/bundle-exec.1.txt +0 -178
  235. data/man/bundle-gem.1.txt +0 -91
  236. data/man/bundle-info.1.txt +0 -21
  237. data/man/bundle-init.1.txt +0 -34
  238. data/man/bundle-inject.1.txt +0 -32
  239. data/man/bundle-install.1.txt +0 -401
  240. data/man/bundle-list.1.txt +0 -43
  241. data/man/bundle-lock.1.txt +0 -93
  242. data/man/bundle-open.1.txt +0 -29
  243. data/man/bundle-outdated.1.txt +0 -131
  244. data/man/bundle-platform.1.txt +0 -57
  245. data/man/bundle-pristine.1.txt +0 -44
  246. data/man/bundle-remove.1.txt +0 -34
  247. data/man/bundle-show.1.txt +0 -27
  248. data/man/bundle-update.1.txt +0 -390
  249. data/man/bundle-viz.1.txt +0 -39
  250. data/man/bundle.1.txt +0 -116
  251. data/man/gemfile.5.txt +0 -649
@@ -4,19 +4,18 @@ module Bundler
4
4
  class DepProxy
5
5
  attr_reader :__platform, :dep
6
6
 
7
+ @proxies = {}
8
+
9
+ def self.get_proxy(dep, platform)
10
+ @proxies[[dep, platform]] ||= new(dep, platform).freeze
11
+ end
12
+
7
13
  def initialize(dep, platform)
8
14
  @dep = dep
9
15
  @__platform = platform
10
16
  end
11
17
 
12
- def hash
13
- @hash ||= [dep, __platform].hash
14
- end
15
-
16
- def ==(other)
17
- return false if other.class != self.class
18
- dep == other.dep && __platform == other.__platform
19
- end
18
+ private_class_method :new
20
19
 
21
20
  alias_method :eql?, :==
22
21
 
@@ -39,7 +38,15 @@ module Bundler
39
38
  s
40
39
  end
41
40
 
42
- private
41
+ def dup
42
+ raise NoMethodError.new("DepProxy cannot be duplicated")
43
+ end
44
+
45
+ def clone
46
+ raise NoMethodError.new("DepProxy cannot be cloned")
47
+ end
48
+
49
+ private
43
50
 
44
51
  def method_missing(*args, &blk)
45
52
  @dep.send(*args, &blk)
@@ -74,15 +74,6 @@ module Bundler
74
74
  :x64_mingw_26 => Gem::Platform::X64_MINGW,
75
75
  }.freeze
76
76
 
77
- REVERSE_PLATFORM_MAP = {}.tap do |reverse_platform_map|
78
- PLATFORM_MAP.each do |key, value|
79
- reverse_platform_map[value] ||= []
80
- reverse_platform_map[value] << key
81
- end
82
-
83
- reverse_platform_map.each {|_, platforms| platforms.freeze }
84
- end.freeze
85
-
86
77
  def initialize(name, version, options = {}, &blk)
87
78
  type = options["type"] || :runtime
88
79
  super(name, version, type)
@@ -105,9 +96,11 @@ module Bundler
105
96
  def gem_platforms(valid_platforms)
106
97
  return valid_platforms if @platforms.empty?
107
98
 
99
+ valid_generic_platforms = valid_platforms.map {|p| [p, GemHelpers.generic(p)] }.to_h
108
100
  @gem_platforms ||= expanded_platforms.compact.uniq
109
101
 
110
- valid_platforms & @gem_platforms
102
+ filtered_generic_platforms = valid_generic_platforms.values & @gem_platforms
103
+ valid_generic_platforms.select {|_, v| filtered_generic_platforms.include?(v) }.keys
111
104
  end
112
105
 
113
106
  def expanded_platforms
@@ -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
@@ -18,6 +18,8 @@ module Bundler
18
18
  VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
19
19
  platform platforms type source install_if gemfile].freeze
20
20
 
21
+ GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}.freeze
22
+
21
23
  attr_reader :gemspecs
22
24
  attr_accessor :dependencies
23
25
 
@@ -63,7 +65,7 @@ module Bundler
63
65
  development_group = opts[:development_group] || :development
64
66
  expanded_path = gemfile_root.join(path)
65
67
 
66
- gemspecs = Dir[File.join(expanded_path, "{,*}.gemspec")].map {|g| Bundler.load_gemspec(g) }.compact
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
70
  Index.sort_specs(gemspecs)
69
71
  specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] }
@@ -75,8 +77,7 @@ module Bundler
75
77
 
76
78
  @gemspecs << spec
77
79
 
78
- gem_platforms = Bundler::Dependency::REVERSE_PLATFORM_MAP[Bundler::GemHelpers.generic_local_platform]
79
- gem spec.name, :name => spec.name, :path => path, :glob => glob, :platforms => gem_platforms
80
+ gem spec.name, :name => spec.name, :path => path, :glob => glob
80
81
 
81
82
  group(development_group) do
82
83
  spec.development_dependencies.each do |dep|
@@ -104,8 +105,8 @@ module Bundler
104
105
  if current = @dependencies.find {|d| d.name == dep.name }
105
106
  deleted_dep = @dependencies.delete(current) if current.type == :development
106
107
 
107
- if current.requirement != dep.requirement
108
- unless deleted_dep
108
+ unless deleted_dep
109
+ if current.requirement != dep.requirement
109
110
  return if dep.type == :development
110
111
 
111
112
  update_prompt = ""
@@ -123,17 +124,14 @@ module Bundler
123
124
  raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
124
125
  "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \
125
126
  "#{update_prompt}"
127
+ else
128
+ Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
129
+ "You should probably keep only one of them.\n" \
130
+ "Remove any duplicate entries and specify the gem only once.\n" \
131
+ "While it's not a problem now, it could cause errors if you change the version of one of them later."
126
132
  end
127
133
 
128
- else
129
- Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
130
- "You should probably keep only one of them.\n" \
131
- "Remove any duplicate entries and specify the gem only once.\n" \
132
- "While it's not a problem now, it could cause errors if you change the version of one of them later."
133
- end
134
-
135
- if current.source != dep.source
136
- unless deleted_dep
134
+ if current.source != dep.source
137
135
  return if dep.type == :development
138
136
  raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
139
137
  "You specified that #{dep.name} (#{dep.requirement}) should come from " \
@@ -165,8 +163,7 @@ module Bundler
165
163
  elsif block_given?
166
164
  with_source(@sources.add_rubygems_source("remotes" => source), &blk)
167
165
  else
168
- check_primary_source_safety(@sources)
169
- @sources.global_rubygems_source = source
166
+ @sources.add_global_rubygems_remote(source)
170
167
  end
171
168
  end
172
169
 
@@ -184,24 +181,14 @@ module Bundler
184
181
  end
185
182
 
186
183
  def path(path, options = {}, &blk)
187
- unless block_given?
188
- msg = "You can no longer specify a path source by itself. Instead, \n" \
189
- "either use the :path option on a gem, or specify the gems that \n" \
190
- "bundler should find in the path source by passing a block to \n" \
191
- "the path method, like: \n\n" \
192
- " path 'dir/containing/rails' do\n" \
193
- " gem 'rails'\n" \
194
- " end\n\n"
195
-
196
- raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource?
197
- SharedHelpers.major_deprecation(2, msg.strip)
198
- end
199
-
200
184
  source_options = normalize_hash(options).merge(
201
185
  "path" => Pathname.new(path),
202
186
  "root_path" => gemfile_root,
203
187
  "gemspec" => gemspecs.find {|g| g.name == options["name"] }
204
188
  )
189
+
190
+ source_options["global"] = true unless block_given?
191
+
205
192
  source = @sources.add_path_source(source_options)
206
193
  with_source(source, &blk)
207
194
  end
@@ -223,7 +210,6 @@ module Bundler
223
210
 
224
211
  def github(repo, options = {})
225
212
  raise ArgumentError, "GitHub sources require a block" unless block_given?
226
- raise DeprecatedError, "The #github method has been removed" if Bundler.feature_flag.skip_default_git_sources?
227
213
  github_uri = @git_sources["github"].call(repo)
228
214
  git_options = normalize_hash(options).merge("uri" => github_uri)
229
215
  git_source = @sources.add_git_source(git_options)
@@ -231,6 +217,7 @@ module Bundler
231
217
  end
232
218
 
233
219
  def to_definition(lockfile, unlock)
220
+ check_primary_source_safety
234
221
  Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version, @optional_groups, @gemfiles)
235
222
  end
236
223
 
@@ -281,17 +268,29 @@ module Bundler
281
268
  raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile"
282
269
  end
283
270
 
284
- private
271
+ def check_primary_source_safety
272
+ check_path_source_safety
273
+ check_rubygems_source_safety
274
+ end
285
275
 
286
- def add_git_sources
287
- return if Bundler.feature_flag.skip_default_git_sources?
276
+ private
288
277
 
278
+ def add_git_sources
289
279
  git_source(:github) do |repo_name|
290
280
  warn_deprecated_git_source(:github, <<-'RUBY'.strip, 'Change any "reponame" :github sources to "username/reponame".')
291
281
  "https://github.com/#{repo_name}.git"
292
282
  RUBY
293
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
294
- "https://github.com/#{repo_name}.git"
283
+ if repo_name =~ GITHUB_PULL_REQUEST_URL
284
+ {
285
+ "git" => "https://github.com/#{$1}.git",
286
+ "branch" => "refs/pull/#{$2}/head",
287
+ "ref" => nil,
288
+ "tag" => nil,
289
+ }
290
+ else
291
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
292
+ "https://github.com/#{repo_name}.git"
293
+ end
295
294
  end
296
295
 
297
296
  git_source(:gist) do |repo_name|
@@ -377,7 +376,11 @@ repo_name ||= user_name
377
376
 
378
377
  git_name = (git_names & opts.keys).last
379
378
  if @git_sources[git_name]
380
- opts["git"] = @git_sources[git_name].call(opts[git_name])
379
+ git_opts = @git_sources[git_name].call(opts[git_name])
380
+ git_opts = { "git" => git_opts } if git_opts.is_a?(String)
381
+ opts.merge!(git_opts) do |key, _gemfile_value, _git_source_value|
382
+ raise GemfileError, %(The :#{key} option can't be used with `#{git_name}: #{opts[git_name].inspect}`)
383
+ end
381
384
  end
382
385
 
383
386
  %w[git path].each do |type|
@@ -444,25 +447,46 @@ repo_name ||= user_name
444
447
  end
445
448
  end
446
449
 
447
- def check_primary_source_safety(source_list)
448
- return if source_list.rubygems_primary_remotes.empty? && source_list.global_rubygems_source.nil?
450
+ def check_path_source_safety
451
+ return if @sources.global_path_source.nil?
452
+
453
+ msg = "You can no longer specify a path source by itself. Instead, \n" \
454
+ "either use the :path option on a gem, or specify the gems that \n" \
455
+ "bundler should find in the path source by passing a block to \n" \
456
+ "the path method, like: \n\n" \
457
+ " path 'dir/containing/rails' do\n" \
458
+ " gem 'rails'\n" \
459
+ " end\n\n"
449
460
 
450
- if Bundler.feature_flag.disable_multisource?
461
+ SharedHelpers.major_deprecation(2, msg.strip)
462
+ end
463
+
464
+ def check_rubygems_source_safety
465
+ if @sources.implicit_global_source?
466
+ implicit_global_source_warning
467
+ elsif @sources.aggregate_global_source?
468
+ multiple_global_source_warning
469
+ end
470
+ end
471
+
472
+ def implicit_global_source_warning
473
+ Bundler::SharedHelpers.major_deprecation 2, "This Gemfile does not include an explicit global source. " \
474
+ "Not using an explicit global source may result in a different lockfile being generated depending on " \
475
+ "the gems you have installed locally before bundler is run. " \
476
+ "Instead, define a global source in your Gemfile like this: source \"https://rubygems.org\"."
477
+ end
478
+
479
+ def multiple_global_source_warning
480
+ if Bundler.feature_flag.bundler_3_mode?
451
481
  msg = "This Gemfile contains multiple primary sources. " \
452
482
  "Each source after the first must include a block to indicate which gems " \
453
483
  "should come from that source"
454
- unless Bundler.feature_flag.bundler_2_mode?
455
- msg += ". To downgrade this error to a warning, run " \
456
- "`bundle config unset disable_multisource`"
457
- end
458
484
  raise GemfileEvalError, msg
459
485
  else
460
486
  Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \
461
487
  "Using `source` more than once without a block is a security risk, and " \
462
488
  "may result in installing unexpected gems. To resolve this warning, use " \
463
- "a block to indicate which gems should come from the secondary source. " \
464
- "To upgrade this warning to an error, run `bundle config set " \
465
- "disable_multisource true`."
489
+ "a block to indicate which gems should come from the secondary source."
466
490
  end
467
491
  end
468
492
 
@@ -571,7 +595,7 @@ The :#{name} git source is deprecated, and will be removed in the future.#{addit
571
595
  end
572
596
  end
573
597
 
574
- private
598
+ private
575
599
 
576
600
  def parse_line_number_from_description
577
601
  description = self.description
@@ -104,7 +104,7 @@ module Bundler
104
104
  @remote_specification = spec
105
105
  end
106
106
 
107
- private
107
+ private
108
108
 
109
109
  def local_specification_path
110
110
  "#{base_dir}/specifications/#{full_name}.gemspec"
data/lib/bundler/env.rb CHANGED
@@ -105,7 +105,7 @@ module Bundler
105
105
  out << [" User Home", Gem.user_home]
106
106
  out << [" User Path", Gem.user_dir]
107
107
  out << [" Bin Dir", Gem.bindir]
108
- if defined?(OpenSSL)
108
+ if defined?(OpenSSL::SSL)
109
109
  out << ["OpenSSL"]
110
110
  out << [" Compiled", OpenSSL::OPENSSL_VERSION] if defined?(OpenSSL::OPENSSL_VERSION)
111
111
  out << [" Loaded", OpenSSL::OPENSSL_LIBRARY_VERSION] if defined?(OpenSSL::OPENSSL_LIBRARY_VERSION)
@@ -17,14 +17,41 @@ module Bundler
17
17
  ].map(&:freeze).freeze
18
18
  BUNDLER_PREFIX = "BUNDLER_ORIG_".freeze
19
19
 
20
- # @param env [ENV]
20
+ def self.from_env
21
+ new(env_to_hash(ENV), BUNDLER_KEYS)
22
+ end
23
+
24
+ def self.env_to_hash(env)
25
+ to_hash = env.to_hash
26
+ return to_hash unless Gem.win_platform?
27
+
28
+ to_hash.each_with_object({}) {|(k,v), a| a[k.upcase] = v }
29
+ end
30
+
31
+ # @param env [Hash]
21
32
  # @param keys [Array<String>]
22
33
  def initialize(env, keys)
23
- @original = env.to_hash
34
+ @original = env
24
35
  @keys = keys
25
36
  @prefix = BUNDLER_PREFIX
26
37
  end
27
38
 
39
+ # Replaces `ENV` with the bundler environment variables backed up
40
+ def replace_with_backup
41
+ unless Gem.win_platform?
42
+ ENV.replace(backup)
43
+ return
44
+ end
45
+
46
+ # Fallback logic for Windows below to workaround
47
+ # https://bugs.ruby-lang.org/issues/16798. Can be dropped once all
48
+ # supported rubies include the fix for that.
49
+
50
+ ENV.clear
51
+
52
+ backup.each {|k, v| ENV[k] = v }
53
+ end
54
+
28
55
  # @return [Hash]
29
56
  def backup
30
57
  env = @original.clone
@@ -56,6 +56,7 @@ module Bundler
56
56
  class SudoNotPermittedError < BundlerError; status_code(30); end
57
57
  class ThreadCreationError < BundlerError; status_code(33); end
58
58
  class APIResponseMismatchError < BundlerError; status_code(34); end
59
+ class APIResponseInvalidDependenciesError < BundlerError; status_code(35); end
59
60
  class GemfileEvalError < GemfileError; end
60
61
  class MarshalError < StandardError; end
61
62
 
@@ -74,10 +75,26 @@ module Bundler
74
75
  end
75
76
  end
76
77
 
78
+ def permission_type
79
+ case @permission_type
80
+ when :create
81
+ "executable permissions for all parent directories and write permissions for `#{parent_folder}`"
82
+ when :delete
83
+ permissions = "executable permissions for all parent directories and write permissions for `#{parent_folder}`"
84
+ permissions += ", and the same thing for all subdirectories inside #{@path}" if File.directory?(@path)
85
+ permissions
86
+ else
87
+ "#{@permission_type} permissions for that path"
88
+ end
89
+ end
90
+
91
+ def parent_folder
92
+ File.dirname(@path)
93
+ end
94
+
77
95
  def message
78
96
  "There was an error while trying to #{action} `#{@path}`. " \
79
- "It is likely that you need to grant #{@permission_type} permissions " \
80
- "for that path."
97
+ "It is likely that you need to grant #{permission_type}."
81
98
  end
82
99
 
83
100
  status_code(23)
@@ -121,7 +138,7 @@ module Bundler
121
138
 
122
139
  class VirtualProtocolError < BundlerError
123
140
  def message
124
- "There was an error relating to virtualization and file access." \
141
+ "There was an error relating to virtualization and file access. " \
125
142
  "It is likely that you need to grant access to or mount some file system correctly."
126
143
  end
127
144
 
@@ -27,25 +27,17 @@ module Bundler
27
27
 
28
28
  (1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } }
29
29
 
30
- settings_flag(:allow_bundler_dependency_conflicts) { bundler_3_mode? }
31
30
  settings_flag(:allow_offline_install) { bundler_3_mode? }
32
31
  settings_flag(:auto_clean_without_path) { bundler_3_mode? }
33
- settings_flag(:auto_config_jobs) { bundler_3_mode? }
34
32
  settings_flag(:cache_all) { bundler_3_mode? }
35
33
  settings_flag(:default_install_uses_path) { bundler_3_mode? }
36
- settings_flag(:deployment_means_frozen) { bundler_3_mode? }
37
- settings_flag(:disable_multisource) { bundler_3_mode? }
38
34
  settings_flag(:forget_cli_options) { bundler_3_mode? }
39
35
  settings_flag(:global_gem_cache) { bundler_3_mode? }
40
- settings_flag(:only_update_to_newer_versions) { bundler_3_mode? }
41
36
  settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
42
37
  settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
43
38
  settings_flag(:print_only_version_number) { bundler_3_mode? }
44
39
  settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
45
- settings_flag(:skip_default_git_sources) { bundler_3_mode? }
46
- settings_flag(:specific_platform) { bundler_3_mode? }
47
40
  settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
48
- settings_flag(:unlock_source_unlocks_spec) { !bundler_3_mode? }
49
41
  settings_flag(:update_requires_all_flag) { bundler_4_mode? }
50
42
  settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_3_mode? }
51
43
 
@@ -38,7 +38,7 @@ module Bundler
38
38
  false
39
39
  end
40
40
 
41
- private
41
+ private
42
42
 
43
43
  def log_specs(debug_msg)
44
44
  if Bundler.ui.debug?
@@ -83,7 +83,7 @@ module Bundler
83
83
  true
84
84
  end
85
85
 
86
- private
86
+ private
87
87
 
88
88
  def compact_index_client
89
89
  @compact_index_client ||=
@@ -111,7 +111,7 @@ module Bundler
111
111
  def bundle_worker(func = nil)
112
112
  @bundle_worker ||= begin
113
113
  worker_name = "Compact Index (#{display_uri.host})"
114
- Bundler::Worker.new(Bundler.current_ruby.rbx? ? 1 : 25, worker_name, func)
114
+ Bundler::Worker.new(Bundler.settings.processor_count, worker_name, func)
115
115
  end
116
116
  @bundle_worker.tap do |worker|
117
117
  worker.instance_variable_set(:@func, func) if func
@@ -14,8 +14,10 @@ module Bundler
14
14
  def fetch(uri, headers = {}, counter = 0)
15
15
  raise HTTPError, "Too many redirects" if counter >= redirect_limit
16
16
 
17
+ filtered_uri = URICredentialsFilter.credential_filtered_uri(uri)
18
+
17
19
  response = request(uri, headers)
18
- Bundler.ui.debug("HTTP #{response.code} #{response.message} #{uri}")
20
+ Bundler.ui.debug("HTTP #{response.code} #{response.message} #{filtered_uri}")
19
21
 
20
22
  case response
21
23
  when Net::HTTPSuccess, Net::HTTPNotModified
@@ -40,7 +42,7 @@ module Bundler
40
42
  raise BadAuthenticationError, uri.host if uri.userinfo
41
43
  raise AuthenticationRequiredError, uri.host
42
44
  when Net::HTTPNotFound
43
- raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}"
45
+ raise FallbackError, "Net::HTTPNotFound: #{filtered_uri}"
44
46
  else
45
47
  raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}"
46
48
  end
@@ -49,7 +51,9 @@ module Bundler
49
51
  def request(uri, headers)
50
52
  validate_uri_scheme!(uri)
51
53
 
52
- Bundler.ui.debug "HTTP GET #{uri}"
54
+ filtered_uri = URICredentialsFilter.credential_filtered_uri(uri)
55
+
56
+ Bundler.ui.debug "HTTP GET #{filtered_uri}"
53
57
  req = Net::HTTP::Get.new uri.request_uri, headers
54
58
  if uri.user
55
59
  user = CGI.unescape(uri.user)
@@ -64,17 +68,16 @@ module Bundler
64
68
  raise CertificateFailureError.new(uri)
65
69
  rescue *HTTP_ERRORS => e
66
70
  Bundler.ui.trace e
67
- case e.message
68
- when /host down:/, /getaddrinfo: nodename nor servname provided/
71
+ if e.is_a?(SocketError) || e.message =~ /host down:/
69
72
  raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
70
73
  "connection and try again."
71
74
  else
72
- raise HTTPError, "Network error while fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" \
75
+ raise HTTPError, "Network error while fetching #{filtered_uri}" \
73
76
  " (#{e})"
74
77
  end
75
78
  end
76
79
 
77
- private
80
+ private
78
81
 
79
82
  def validate_uri_scheme!(uri)
80
83
  return if uri.scheme =~ /\Ahttps?\z/
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "base"
4
- require "rubygems/remote_fetcher"
5
4
 
6
5
  module Bundler
7
6
  class Fetcher
8
7
  class Index < Base
9
8
  def specs(_gem_names)
10
9
  Bundler.rubygems.fetch_all_remote_specs(remote)
11
- rescue Gem::RemoteFetcher::FetchError, OpenSSL::SSL::SSLError, Net::HTTPFatalError => e
10
+ rescue Gem::RemoteFetcher::FetchError => e
12
11
  case e.message
13
12
  when /certificate verify failed/
14
13
  raise CertificateFailureError.new(display_uri)
@@ -19,8 +18,7 @@ module Bundler
19
18
  raise BadAuthenticationError, remote_uri if remote_uri.userinfo
20
19
  raise AuthenticationRequiredError, remote_uri
21
20
  else
22
- Bundler.ui.trace e
23
- raise HTTPError, "Could not fetch specs from #{display_uri}"
21
+ raise HTTPError, "Could not fetch specs from #{display_uri} due to underlying error <#{e.message}>"
24
22
  end
25
23
  end
26
24
 
@@ -42,7 +40,7 @@ module Bundler
42
40
  "Your network or your gem server is probably having issues right now."
43
41
  end
44
42
 
45
- private
43
+ private
46
44
 
47
45
  # cached gem specification path, if one exists
48
46
  def gemspec_cached_path(spec_file_name)
@@ -28,7 +28,8 @@ module Bundler
28
28
  " is a chance you are experiencing a man-in-the-middle attack, but" \
29
29
  " most likely your system doesn't have the CA certificates needed" \
30
30
  " for verification. For information about OpenSSL certificates, see" \
31
- " http://bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile" \
31
+ " https://railsapps.github.io/openssl-certificate-verify-failed.html." \
32
+ " To connect without using SSL, edit your Gemfile" \
32
33
  " sources and change 'https' to 'http'."
33
34
  end
34
35
  end
@@ -47,7 +48,8 @@ module Bundler
47
48
  remote_uri = filter_uri(remote_uri)
48
49
  super "Authentication is required for #{remote_uri}.\n" \
49
50
  "Please supply credentials for this source. You can do this by running:\n" \
50
- " bundle config set #{remote_uri} username:password"
51
+ "`bundle config set --global #{remote_uri} username:password`\n" \
52
+ "or by storing the credentials in the `#{Settings.key_for(remote_uri)}` environment variable"
51
53
  end
52
54
  end
53
55
  # This error is raised if HTTP authentication is provided, but incorrect.
@@ -137,7 +139,6 @@ module Bundler
137
139
  end
138
140
 
139
141
  specs.each do |name, version, platform, dependencies, metadata|
140
- next if name == "bundler"
141
142
  spec = if dependencies
142
143
  EndpointSpecification.new(name, version, platform, dependencies, metadata)
143
144
  else
@@ -216,7 +217,7 @@ module Bundler
216
217
  "#<#{self.class}:0x#{object_id} uri=#{uri}>"
217
218
  end
218
219
 
219
- private
220
+ private
220
221
 
221
222
  FETCHERS = [CompactIndex, Dependency, Index].freeze
222
223
 
@@ -229,6 +230,7 @@ module Bundler
229
230
  "BUILDBOX" => "buildbox",
230
231
  "GO_SERVER_URL" => "go",
231
232
  "SNAP_CI" => "snap",
233
+ "GITLAB_CI" => "gitlab",
232
234
  "CI_NAME" => ENV["CI_NAME"],
233
235
  "CI" => "ci",
234
236
  }
@@ -302,7 +304,7 @@ module Bundler
302
304
  store
303
305
  end
304
306
 
305
- private
307
+ private
306
308
 
307
309
  def remote_uri
308
310
  @remote.uri