bundler 2.1.4 → 2.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2164 -1430
  3. data/README.md +7 -9
  4. data/bundler.gemspec +5 -6
  5. data/exe/bundle +10 -8
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -11
  9. data/lib/bundler/cli/add.rb +1 -1
  10. data/lib/bundler/cli/binstubs.rb +6 -2
  11. data/lib/bundler/cli/cache.rb +3 -8
  12. data/lib/bundler/cli/check.rb +4 -2
  13. data/lib/bundler/cli/clean.rb +1 -1
  14. data/lib/bundler/cli/common.rb +30 -3
  15. data/lib/bundler/cli/config.rb +10 -1
  16. data/lib/bundler/cli/console.rb +1 -1
  17. data/lib/bundler/cli/doctor.rb +25 -6
  18. data/lib/bundler/cli/exec.rb +5 -10
  19. data/lib/bundler/cli/fund.rb +36 -0
  20. data/lib/bundler/cli/gem.rb +219 -28
  21. data/lib/bundler/cli/info.rb +38 -6
  22. data/lib/bundler/cli/init.rb +3 -3
  23. data/lib/bundler/cli/inject.rb +1 -1
  24. data/lib/bundler/cli/install.rb +20 -52
  25. data/lib/bundler/cli/issue.rb +5 -4
  26. data/lib/bundler/cli/list.rb +19 -11
  27. data/lib/bundler/cli/lock.rb +5 -1
  28. data/lib/bundler/cli/open.rb +1 -2
  29. data/lib/bundler/cli/outdated.rb +95 -75
  30. data/lib/bundler/cli/platform.rb +1 -1
  31. data/lib/bundler/cli/plugin.rb +10 -0
  32. data/lib/bundler/cli/pristine.rb +5 -0
  33. data/lib/bundler/cli/remove.rb +1 -2
  34. data/lib/bundler/cli/show.rb +2 -2
  35. data/lib/bundler/cli/update.rb +20 -9
  36. data/lib/bundler/cli.rb +101 -81
  37. data/lib/bundler/compact_index_client/cache.rb +6 -23
  38. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  39. data/lib/bundler/compact_index_client/updater.rb +13 -22
  40. data/lib/bundler/compact_index_client.rb +3 -9
  41. data/lib/bundler/current_ruby.rb +6 -4
  42. data/lib/bundler/definition.rb +201 -385
  43. data/lib/bundler/dep_proxy.rb +16 -9
  44. data/lib/bundler/dependency.rb +23 -14
  45. data/lib/bundler/digest.rb +71 -0
  46. data/lib/bundler/dsl.rb +71 -74
  47. data/lib/bundler/endpoint_specification.rb +22 -12
  48. data/lib/bundler/env.rb +2 -2
  49. data/lib/bundler/environment_preserver.rb +29 -2
  50. data/lib/bundler/errors.rb +20 -3
  51. data/lib/bundler/feature_flag.rb +0 -8
  52. data/lib/bundler/fetcher/base.rb +1 -1
  53. data/lib/bundler/fetcher/compact_index.rb +11 -16
  54. data/lib/bundler/fetcher/downloader.rb +10 -7
  55. data/lib/bundler/fetcher/index.rb +2 -30
  56. data/lib/bundler/fetcher.rb +18 -23
  57. data/lib/bundler/friendly_errors.rb +25 -43
  58. data/lib/bundler/gem_helper.rb +53 -31
  59. data/lib/bundler/gem_helpers.rb +36 -25
  60. data/lib/bundler/gem_version_promoter.rb +4 -4
  61. data/lib/bundler/graph.rb +1 -1
  62. data/lib/bundler/index.rb +9 -9
  63. data/lib/bundler/injector.rb +33 -6
  64. data/lib/bundler/inline.rb +3 -2
  65. data/lib/bundler/installer/gem_installer.rb +7 -25
  66. data/lib/bundler/installer/parallel_installer.rb +46 -25
  67. data/lib/bundler/installer/standalone.rb +30 -10
  68. data/lib/bundler/installer.rb +36 -59
  69. data/lib/bundler/lazy_specification.rb +62 -26
  70. data/lib/bundler/lockfile_generator.rb +2 -2
  71. data/lib/bundler/lockfile_parser.rb +17 -46
  72. data/lib/bundler/man/.document +1 -0
  73. data/{man → lib/bundler/man}/bundle-add.1 +10 -2
  74. data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +7 -1
  75. data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  76. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  77. data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
  78. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  79. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  80. data/{man → lib/bundler/man}/bundle-config.1 +44 -45
  81. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +59 -60
  82. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  83. data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
  84. data/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  85. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  86. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  87. data/{man → lib/bundler/man}/bundle-init.1 +1 -1
  88. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  89. data/{man → lib/bundler/man}/bundle-install.1 +31 -4
  90. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +27 -5
  91. data/{man → lib/bundler/man}/bundle-list.1 +7 -7
  92. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  93. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  94. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  95. data/{man → lib/bundler/man}/bundle-outdated.1 +3 -10
  96. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +1 -10
  97. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  98. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  99. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  100. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  101. data/{man → lib/bundler/man}/bundle-update.1 +5 -5
  102. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +5 -4
  103. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  104. data/{man → lib/bundler/man}/bundle.1 +1 -1
  105. data/{man → lib/bundler/man}/gemfile.5 +31 -5
  106. data/{man → lib/bundler/man}/gemfile.5.ronn +13 -5
  107. data/lib/bundler/mirror.rb +2 -2
  108. data/lib/bundler/plugin/api/source.rb +23 -7
  109. data/lib/bundler/plugin/dsl.rb +1 -1
  110. data/lib/bundler/plugin/index.rb +13 -1
  111. data/lib/bundler/plugin/installer/rubygems.rb +1 -1
  112. data/lib/bundler/plugin/installer.rb +11 -11
  113. data/lib/bundler/plugin/source_list.rb +5 -1
  114. data/lib/bundler/plugin.rb +56 -11
  115. data/lib/bundler/process_lock.rb +1 -1
  116. data/lib/bundler/remote_specification.rb +12 -2
  117. data/lib/bundler/resolver/spec_group.rb +58 -55
  118. data/lib/bundler/resolver.rb +176 -177
  119. data/lib/bundler/retry.rb +2 -2
  120. data/lib/bundler/ruby_version.rb +2 -15
  121. data/lib/bundler/rubygems_ext.rb +137 -28
  122. data/lib/bundler/rubygems_gem_installer.rb +69 -8
  123. data/lib/bundler/rubygems_integration.rb +69 -133
  124. data/lib/bundler/runtime.rb +22 -25
  125. data/lib/bundler/self_manager.rb +168 -0
  126. data/lib/bundler/settings.rb +144 -65
  127. data/lib/bundler/setup.rb +2 -2
  128. data/lib/bundler/shared_helpers.rb +12 -27
  129. data/lib/bundler/similarity_detector.rb +1 -1
  130. data/lib/bundler/source/git/git_proxy.rb +88 -84
  131. data/lib/bundler/source/git.rb +43 -23
  132. data/lib/bundler/source/metadata.rb +3 -7
  133. data/lib/bundler/source/path/installer.rb +10 -10
  134. data/lib/bundler/source/path.rb +10 -4
  135. data/lib/bundler/source/rubygems/remote.rb +1 -1
  136. data/lib/bundler/source/rubygems.rb +126 -116
  137. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  138. data/lib/bundler/source.rb +22 -1
  139. data/lib/bundler/source_list.rb +101 -63
  140. data/lib/bundler/source_map.rb +71 -0
  141. data/lib/bundler/spec_set.rb +26 -41
  142. data/lib/bundler/stub_specification.rb +25 -7
  143. data/lib/bundler/templates/Executable +2 -4
  144. data/lib/bundler/templates/Executable.bundler +8 -8
  145. data/lib/bundler/templates/Executable.standalone +2 -4
  146. data/lib/bundler/templates/Gemfile +0 -2
  147. data/lib/bundler/templates/gems.rb +0 -3
  148. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  149. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  150. data/lib/bundler/templates/newgem/Gemfile.tt +12 -1
  151. data/lib/bundler/templates/newgem/README.md.tt +9 -14
  152. data/lib/bundler/templates/newgem/Rakefile.tt +32 -5
  153. data/lib/bundler/templates/newgem/bin/console.tt +1 -0
  154. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  155. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  156. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  157. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  158. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  159. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  160. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
  161. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  162. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  163. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  164. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  165. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  166. data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  167. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  168. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  169. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  170. data/lib/bundler/ui/shell.rb +6 -6
  171. data/lib/bundler/uri_credentials_filter.rb +3 -1
  172. data/lib/bundler/vendor/.document +1 -0
  173. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  174. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  175. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  176. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  177. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  178. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  179. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  180. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  181. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  182. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  183. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +37 -5
  184. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +34 -28
  185. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  186. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  187. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  188. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  189. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  190. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  191. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  192. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  193. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +9 -7
  194. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  195. data/lib/bundler/vendor/thor/lib/thor/actions.rb +7 -3
  196. data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  197. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  198. data/lib/bundler/vendor/thor/lib/thor/error.rb +10 -5
  199. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  200. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +28 -9
  201. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +27 -6
  202. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  203. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  204. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  205. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  206. data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  207. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  208. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  209. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  210. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  211. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  212. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  213. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  214. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  215. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  216. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  217. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  218. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  219. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  220. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  221. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  222. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  223. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  224. data/lib/bundler/vendored_persistent.rb +0 -7
  225. data/lib/bundler/vendored_tmpdir.rb +4 -0
  226. data/lib/bundler/vendored_tsort.rb +4 -0
  227. data/lib/bundler/version.rb +1 -1
  228. data/lib/bundler/worker.rb +20 -5
  229. data/lib/bundler/yaml_serializer.rb +1 -1
  230. data/lib/bundler.rb +64 -43
  231. metadata +94 -91
  232. data/lib/bundler/gemdeps.rb +0 -29
  233. data/lib/bundler/psyched_yaml.rb +0 -37
  234. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  235. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  236. data/man/bundle-add.1.txt +0 -58
  237. data/man/bundle-binstubs.1.txt +0 -48
  238. data/man/bundle-cache.1.txt +0 -78
  239. data/man/bundle-check.1.txt +0 -33
  240. data/man/bundle-clean.1.txt +0 -26
  241. data/man/bundle-config.1.txt +0 -528
  242. data/man/bundle-doctor.1.txt +0 -44
  243. data/man/bundle-exec.1.txt +0 -178
  244. data/man/bundle-gem.1.txt +0 -91
  245. data/man/bundle-info.1.txt +0 -21
  246. data/man/bundle-init.1.txt +0 -34
  247. data/man/bundle-inject.1.txt +0 -32
  248. data/man/bundle-install.1.txt +0 -401
  249. data/man/bundle-list.1.txt +0 -43
  250. data/man/bundle-lock.1.txt +0 -93
  251. data/man/bundle-open.1.txt +0 -29
  252. data/man/bundle-outdated.1.txt +0 -131
  253. data/man/bundle-platform.1.txt +0 -57
  254. data/man/bundle-pristine.1.txt +0 -44
  255. data/man/bundle-remove.1.txt +0 -34
  256. data/man/bundle-show.1.txt +0 -27
  257. data/man/bundle-update.1.txt +0 -390
  258. data/man/bundle-viz.1.txt +0 -39
  259. data/man/bundle.1.txt +0 -116
  260. data/man/gemfile.5.txt +0 -649
  261. /data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
  262. /data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  263. /data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  264. /data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  265. /data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
  266. /data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  267. /data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  268. /data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
  269. /data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  270. /data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  271. /data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
  272. /data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  273. /data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  274. /data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  275. /data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
  276. /data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
  277. /data/{man → lib/bundler/man}/index.txt +0 -0
@@ -12,32 +12,30 @@ module Bundler
12
12
  EXT_LOCK = Monitor.new
13
13
  end
14
14
 
15
- def self.version
16
- @version ||= Gem::Version.new(Gem::VERSION)
17
- end
18
-
19
- def self.provides?(req_str)
20
- Gem::Requirement.new(req_str).satisfied_by?(version)
21
- end
22
-
23
15
  def initialize
24
16
  @replaced_methods = {}
25
17
  backport_ext_builder_monitor
26
18
  end
27
19
 
28
20
  def version
29
- self.class.version
21
+ @version ||= Gem.rubygems_version
30
22
  end
31
23
 
32
24
  def provides?(req_str)
33
- self.class.provides?(req_str)
25
+ Gem::Requirement.new(req_str).satisfied_by?(version)
26
+ end
27
+
28
+ def supports_bundler_trampolining?
29
+ provides?(">= 3.3.0.a")
34
30
  end
35
31
 
36
32
  def build_args
33
+ require "rubygems/command"
37
34
  Gem::Command.build_args
38
35
  end
39
36
 
40
37
  def build_args=(args)
38
+ require "rubygems/command"
41
39
  Gem::Command.build_args = args
42
40
  end
43
41
 
@@ -84,16 +82,12 @@ module Bundler
84
82
  def spec_missing_extensions?(spec, default = true)
85
83
  return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
86
84
 
87
- return false if spec_default_gem?(spec)
85
+ return false if spec.default_gem?
88
86
  return false if spec.extensions.empty?
89
87
 
90
88
  default
91
89
  end
92
90
 
93
- def spec_default_gem?(spec)
94
- spec.respond_to?(:default_gem?) && spec.default_gem?
95
- end
96
-
97
91
  def spec_matches_for_glob(spec, glob)
98
92
  return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
99
93
 
@@ -102,11 +96,6 @@ module Bundler
102
96
  end.flatten(1)
103
97
  end
104
98
 
105
- def spec_extension_dir(spec)
106
- return unless spec.respond_to?(:extension_dir)
107
- spec.extension_dir
108
- end
109
-
110
99
  def stub_set_spec(stub, spec)
111
100
  stub.instance_variable_set(:@spec, spec)
112
101
  end
@@ -115,23 +104,6 @@ module Bundler
115
104
  obj.to_s
116
105
  end
117
106
 
118
- def platforms
119
- return [Gem::Platform::RUBY] if Bundler.settings[:force_ruby_platform]
120
- Gem.platforms
121
- end
122
-
123
- def configuration
124
- require_relative "psyched_yaml"
125
- Gem.configuration
126
- rescue Gem::SystemExitException, LoadError => e
127
- Bundler.ui.error "#{e.class}: #{e.message}"
128
- Bundler.ui.trace e
129
- raise
130
- rescue YamlLibrarySyntaxError => e
131
- raise YamlSyntaxError.new(e, "Your RubyGems configuration, which is " \
132
- "usually located in ~/.gemrc, contains invalid YAML syntax.")
133
- end
134
-
135
107
  def ruby_engine
136
108
  Gem.ruby_engine
137
109
  end
@@ -141,14 +113,10 @@ module Bundler
141
113
  end
142
114
 
143
115
  def inflate(obj)
144
- require "rubygems/util"
145
-
146
116
  Gem::Util.inflate(obj)
147
117
  end
148
118
 
149
119
  def correct_for_windows_path(path)
150
- require "rubygems/util"
151
-
152
120
  if Gem::Util.respond_to?(:correct_for_windows_path)
153
121
  Gem::Util.correct_for_windows_path(path)
154
122
  elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
@@ -158,19 +126,6 @@ module Bundler
158
126
  end
159
127
  end
160
128
 
161
- def sources=(val)
162
- # Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
163
- # If that file exists, its settings (including sources) will overwrite the values we
164
- # are about to set here. In order to avoid that, we force memoizing the config file now.
165
- configuration
166
-
167
- Gem.sources = val
168
- end
169
-
170
- def sources
171
- Gem.sources
172
- end
173
-
174
129
  def gem_dir
175
130
  Gem.dir
176
131
  end
@@ -223,11 +178,6 @@ module Bundler
223
178
  Gem.bin_path(gem, bin, ver)
224
179
  end
225
180
 
226
- def preserve_paths
227
- # this is a no-op outside of RubyGems 1.8
228
- yield
229
- end
230
-
231
181
  def loaded_gem_paths
232
182
  loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
233
183
  loaded_gem_paths.flatten
@@ -241,6 +191,10 @@ module Bundler
241
191
  Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files)
242
192
  end
243
193
 
194
+ def load_env_plugins
195
+ Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
196
+ end
197
+
244
198
  def ui=(obj)
245
199
  Gem::DefaultUserInteraction.ui = obj
246
200
  end
@@ -249,24 +203,10 @@ module Bundler
249
203
  EXT_LOCK
250
204
  end
251
205
 
252
- def with_build_args(args)
253
- ext_lock.synchronize do
254
- old_args = build_args
255
- begin
256
- self.build_args = args
257
- yield
258
- ensure
259
- self.build_args = old_args
260
- end
261
- end
262
- end
263
-
264
206
  def spec_from_gem(path, policy = nil)
265
207
  require "rubygems/security"
266
- require_relative "psyched_yaml"
208
+ require "psych"
267
209
  gem_from_path(path, security_policies[policy]).spec
268
- rescue Gem::Package::FormatError
269
- raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
270
210
  rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException
271
211
  if e.is_a?(Gem::Security::Exception) ||
272
212
  e.message =~ /unknown trust policy|unsigned gem/i ||
@@ -329,8 +269,13 @@ module Bundler
329
269
  end
330
270
 
331
271
  message = if spec.nil?
272
+ target_file = begin
273
+ Bundler.default_gemfile.basename
274
+ rescue GemfileNotFound
275
+ "inline Gemfile"
276
+ end
332
277
  "#{dep.name} is not part of the bundle." \
333
- " Add it to your #{Bundler.default_gemfile.basename}."
278
+ " Add it to your #{target_file}."
334
279
  else
335
280
  "can't activate #{dep}, already activated #{spec.full_name}. " \
336
281
  "Make sure all dependencies are added to Gemfile."
@@ -346,7 +291,7 @@ module Bundler
346
291
  raise e
347
292
  end
348
293
 
349
- # backwards compatibility shim, see https://github.com/bundler/bundler/issues/5102
294
+ # backwards compatibility shim, see https://github.com/rubygems/bundler/issues/5102
350
295
  kernel_class.send(:public, :gem) if Bundler.feature_flag.setup_makes_kernel_gem_public?
351
296
  end
352
297
  end
@@ -422,6 +367,17 @@ module Bundler
422
367
  # Replace or hook into RubyGems to provide a bundlerized view
423
368
  # of the world.
424
369
  def replace_entrypoints(specs)
370
+ specs_by_name = add_default_gems_to(specs)
371
+
372
+ replace_gem(specs, specs_by_name)
373
+ stub_rubygems(specs)
374
+ replace_bin_path(specs_by_name)
375
+
376
+ Gem.clear_paths
377
+ end
378
+
379
+ # Add default gems not already present in specs, and return them as a hash.
380
+ def add_default_gems_to(specs)
425
381
  specs_by_name = specs.reduce({}) do |h, s|
426
382
  h[s.name] = s
427
383
  h
@@ -436,40 +392,7 @@ module Bundler
436
392
  specs_by_name[default_spec_name] = default_spec
437
393
  end
438
394
 
439
- replace_gem(specs, specs_by_name)
440
- stub_rubygems(specs)
441
- replace_bin_path(specs_by_name)
442
-
443
- Gem.clear_paths
444
- end
445
-
446
- # This backports base_dir which replaces installation path
447
- # RubyGems 1.8+
448
- def backport_base_dir
449
- redefine_method(Gem::Specification, :base_dir) do
450
- return Gem.dir unless loaded_from
451
- File.dirname File.dirname loaded_from
452
- end
453
- end
454
-
455
- def backport_cache_file
456
- redefine_method(Gem::Specification, :cache_dir) do
457
- @cache_dir ||= File.join base_dir, "cache"
458
- end
459
-
460
- redefine_method(Gem::Specification, :cache_file) do
461
- @cache_file ||= File.join cache_dir, "#{full_name}.gem"
462
- end
463
- end
464
-
465
- def backport_spec_file
466
- redefine_method(Gem::Specification, :spec_dir) do
467
- @spec_dir ||= File.join base_dir, "specifications"
468
- end
469
-
470
- redefine_method(Gem::Specification, :spec_file) do
471
- @spec_file ||= File.join spec_dir, "#{full_name}.gemspec"
472
- end
395
+ specs_by_name
473
396
  end
474
397
 
475
398
  def undo_replacements
@@ -536,14 +459,15 @@ module Bundler
536
459
  end
537
460
 
538
461
  def fetch_specs(remote, name)
462
+ require "rubygems/remote_fetcher"
539
463
  path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz"
540
464
  fetcher = gem_remote_fetcher
541
465
  fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
542
466
  string = fetcher.fetch_path(path)
543
467
  Bundler.load_marshal(string)
544
- rescue Gem::RemoteFetcher::FetchError => e
468
+ rescue Gem::RemoteFetcher::FetchError
545
469
  # it's okay for prerelease to fail
546
- raise e unless name == "prerelease_specs"
470
+ raise unless name == "prerelease_specs"
547
471
  end
548
472
 
549
473
  def fetch_all_remote_specs(remote)
@@ -553,20 +477,41 @@ module Bundler
553
477
  specs.concat(pres)
554
478
  end
555
479
 
556
- def download_gem(spec, uri, path)
480
+ def download_gem(spec, uri, cache_dir)
481
+ require "rubygems/remote_fetcher"
557
482
  uri = Bundler.settings.mirror_for(uri)
558
483
  fetcher = gem_remote_fetcher
559
484
  fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
560
485
  Bundler::Retry.new("download gem from #{uri}").attempts do
561
- fetcher.download(spec, uri, path)
486
+ gem_file_name = spec.file_name
487
+ local_gem_path = File.join cache_dir, gem_file_name
488
+ return if File.exist? local_gem_path
489
+
490
+ begin
491
+ remote_gem_path = uri + "gems/#{gem_file_name}"
492
+ remote_gem_path = remote_gem_path.to_s if provides?("< 3.2.0.rc.1")
493
+
494
+ SharedHelpers.filesystem_access(local_gem_path) do
495
+ fetcher.cache_update_path remote_gem_path, local_gem_path
496
+ end
497
+ rescue Gem::RemoteFetcher::FetchError
498
+ raise if spec.original_platform == spec.platform
499
+
500
+ original_gem_file_name = "#{spec.original_name}.gem"
501
+ raise if gem_file_name == original_gem_file_name
502
+
503
+ gem_file_name = original_gem_file_name
504
+ retry
505
+ end
562
506
  end
507
+ rescue Gem::RemoteFetcher::FetchError => e
508
+ raise Bundler::HTTPError, "Could not download gem from #{uri} due to underlying error <#{e.message}>"
563
509
  end
564
510
 
565
511
  def gem_remote_fetcher
566
- require "resolv"
567
- proxy = configuration[:http_proxy]
568
- dns = Resolv::DNS.new
569
- Gem::RemoteFetcher.new(proxy, dns)
512
+ require "rubygems/remote_fetcher"
513
+ proxy = Gem.configuration[:http_proxy]
514
+ Gem::RemoteFetcher.new(proxy)
570
515
  end
571
516
 
572
517
  def gem_from_path(path, policy = nil)
@@ -585,16 +530,11 @@ module Bundler
585
530
  Gem::REPOSITORY_SUBDIRECTORIES
586
531
  end
587
532
 
588
- def install_with_build_args(args)
589
- yield
590
- end
591
-
592
533
  def path_separator
593
534
  Gem.path_separator
594
535
  end
595
536
 
596
537
  def all_specs
597
- require_relative "remote_specification"
598
538
  Gem::Specification.stubs.map do |stub|
599
539
  StubSpecification.from_stub(stub)
600
540
  end
@@ -602,10 +542,10 @@ module Bundler
602
542
 
603
543
  def backport_ext_builder_monitor
604
544
  # So we can avoid requiring "rubygems/ext" in its entirety
605
- Gem.module_eval <<-RB, __FILE__, __LINE__ + 1
545
+ Gem.module_eval <<-RUBY, __FILE__, __LINE__ + 1
606
546
  module Ext
607
547
  end
608
- RB
548
+ RUBY
609
549
 
610
550
  require "rubygems/ext/builder"
611
551
 
@@ -619,6 +559,10 @@ module Bundler
619
559
  end
620
560
  end
621
561
 
562
+ def find_bundler(version)
563
+ find_name("bundler").find {|s| s.version.to_s == version }
564
+ end
565
+
622
566
  def find_name(name)
623
567
  Gem::Specification.stubs_for(name).map(&:to_spec)
624
568
  end
@@ -632,14 +576,6 @@ module Bundler
632
576
  Gem::Specification.send(:default_stubs, "*.gemspec")
633
577
  end
634
578
  end
635
-
636
- def use_gemdeps(gemfile)
637
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
638
- require_relative "gemdeps"
639
- runtime = Bundler.setup
640
- activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
641
- [Gemdeps.new(runtime), activated_spec_names]
642
- end
643
579
  end
644
580
 
645
581
  def self.rubygems
@@ -12,22 +12,16 @@ module Bundler
12
12
  def setup(*groups)
13
13
  @definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen_bundle?
14
14
 
15
- groups.map!(&:to_sym)
16
-
17
15
  # Has to happen first
18
16
  clean_load_path
19
17
 
20
- specs = groups.any? ? @definition.specs_for(groups) : requested_specs
18
+ specs = @definition.specs_for(groups)
21
19
 
22
20
  SharedHelpers.set_bundle_environment
23
21
  Bundler.rubygems.replace_entrypoints(specs)
24
22
 
25
23
  # Activate the specs
26
24
  load_paths = specs.map do |spec|
27
- unless spec.loaded_from
28
- raise GemNotFound, "#{spec.full_name} is missing. Run `bundle install` to get it."
29
- end
30
-
31
25
  check_for_activated_spec!(spec)
32
26
 
33
27
  Bundler.rubygems.mark_loaded(spec)
@@ -43,14 +37,6 @@ module Bundler
43
37
  self
44
38
  end
45
39
 
46
- REQUIRE_ERRORS = [
47
- /^no such file to load -- (.+)$/i,
48
- /^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
49
- /^Missing API definition file in (.+)$/i,
50
- /^cannot load such file -- (.+)$/i,
51
- /^dlopen\([^)]*\): Library not loaded: (.+)$/i,
52
- ].freeze
53
-
54
40
  def require(*groups)
55
41
  groups.map!(&:to_sym)
56
42
  groups = [:default] if groups.empty?
@@ -79,16 +65,14 @@ module Bundler
79
65
  end
80
66
  end
81
67
  rescue LoadError => e
82
- REQUIRE_ERRORS.find {|r| r =~ e.message }
83
- raise if dep.autorequire || $1 != required_file
68
+ raise if dep.autorequire || e.path != required_file
84
69
 
85
70
  if dep.autorequire.nil? && dep.name.include?("-")
86
71
  begin
87
72
  namespaced_file = dep.name.tr("-", "/")
88
73
  Kernel.require namespaced_file
89
74
  rescue LoadError => e
90
- REQUIRE_ERRORS.find {|r| r =~ e.message }
91
- raise if $1 != namespaced_file
75
+ raise if e.path != namespaced_file
92
76
  end
93
77
  end
94
78
  end
@@ -116,7 +100,7 @@ module Bundler
116
100
 
117
101
  alias_method :gems, :specs
118
102
 
119
- def cache(custom_path = nil)
103
+ def cache(custom_path = nil, local = false)
120
104
  cache_path = Bundler.app_cache(custom_path)
121
105
  SharedHelpers.filesystem_access(cache_path) do |p|
122
106
  FileUtils.mkdir_p(p)
@@ -124,7 +108,20 @@ module Bundler
124
108
 
125
109
  Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
126
110
 
127
- specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
111
+ specs_to_cache = if Bundler.settings[:cache_all_platforms]
112
+ @definition.resolve.materialized_for_all_platforms
113
+ else
114
+ begin
115
+ specs
116
+ rescue GemNotFound
117
+ if local
118
+ Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
119
+ end
120
+
121
+ raise
122
+ end
123
+ end
124
+
128
125
  specs_to_cache.each do |spec|
129
126
  next if spec.name == "bundler"
130
127
  next if spec.source.is_a?(Source::Gemspec)
@@ -165,7 +162,7 @@ module Bundler
165
162
  spec_cache_paths = []
166
163
  spec_gemspec_paths = []
167
164
  spec_extension_paths = []
168
- specs.each do |spec|
165
+ Bundler.rubygems.add_default_gems_to(specs).values.each do |spec|
169
166
  spec_gem_paths << spec.full_gem_path
170
167
  # need to check here in case gems are nested like for the rails git repo
171
168
  md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
@@ -213,7 +210,7 @@ module Bundler
213
210
  output
214
211
  end
215
212
 
216
- private
213
+ private
217
214
 
218
215
  def prune_gem_cache(resolve, cache_path)
219
216
  cached = Dir["#{cache_path}/*.gem"]
@@ -268,7 +265,7 @@ module Bundler
268
265
 
269
266
  return if manuals.empty?
270
267
  Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
271
- ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
268
+ ENV["MANPATH"] ? ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR) : [""]
272
269
  ).uniq.join(File::PATH_SEPARATOR)
273
270
  end
274
271
 
@@ -294,7 +291,7 @@ module Bundler
294
291
  return unless activated_spec = Bundler.rubygems.loaded_specs(spec.name)
295
292
  return if activated_spec.version == spec.version
296
293
 
297
- suggestion = if Bundler.rubygems.spec_default_gem?(activated_spec)
294
+ suggestion = if activated_spec.default_gem?
298
295
  "Since #{spec.name} is a default gem, you can either remove your dependency on it" \
299
296
  " or try updating to a newer version of bundler that supports #{spec.name} as a default gem."
300
297
  else
@@ -0,0 +1,168 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ #
5
+ # This class handles installing and switching to the version of bundler needed
6
+ # by an application.
7
+ #
8
+ class SelfManager
9
+ def restart_with_locked_bundler_if_needed
10
+ return unless needs_switching? && installed?
11
+
12
+ restart_with(lockfile_version)
13
+ end
14
+
15
+ def install_locked_bundler_and_restart_with_it_if_needed
16
+ return unless needs_switching?
17
+
18
+ Bundler.ui.info \
19
+ "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
20
+ "Installing Bundler #{lockfile_version} and restarting using that version."
21
+
22
+ install_and_restart_with(lockfile_version)
23
+ end
24
+
25
+ def update_bundler_and_restart_with_it_if_needed(target)
26
+ return unless autoswitching_applies?
27
+
28
+ spec = resolve_update_version_from(target)
29
+ return unless spec
30
+
31
+ version = spec.version
32
+
33
+ Bundler.ui.info "Updating bundler to #{version}."
34
+
35
+ install(spec)
36
+
37
+ restart_with(version)
38
+ end
39
+
40
+ private
41
+
42
+ def install_and_restart_with(version)
43
+ requirement = Gem::Requirement.new(version)
44
+ spec = find_latest_matching_spec(requirement)
45
+
46
+ if spec.nil?
47
+ Bundler.ui.warn "Your lockfile is locked to a version of bundler (#{lockfile_version}) that doesn't exist at https://rubygems.org/. Going on using #{current_version}"
48
+ return
49
+ end
50
+
51
+ install(spec)
52
+ rescue StandardError => e
53
+ Bundler.ui.trace e
54
+ Bundler.ui.warn "There was an error installing the locked bundler version (#{lockfile_version}), rerun with the `--verbose` flag for more details. Going on using bundler #{current_version}."
55
+ else
56
+ restart_with(version)
57
+ end
58
+
59
+ def install(spec)
60
+ spec.source.install(spec)
61
+ end
62
+
63
+ def restart_with(version)
64
+ configured_gem_home = ENV["GEM_HOME"]
65
+ configured_gem_path = ENV["GEM_PATH"]
66
+
67
+ cmd = [$PROGRAM_NAME, *ARGV]
68
+ cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
69
+
70
+ Bundler.with_original_env do
71
+ Kernel.exec(
72
+ { "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => version.to_s },
73
+ *cmd
74
+ )
75
+ end
76
+ end
77
+
78
+ def needs_switching?
79
+ autoswitching_applies? &&
80
+ released?(lockfile_version) &&
81
+ !running?(lockfile_version) &&
82
+ !updating?
83
+ end
84
+
85
+ def autoswitching_applies?
86
+ ENV["BUNDLER_VERSION"].nil? &&
87
+ Bundler.rubygems.supports_bundler_trampolining? &&
88
+ SharedHelpers.in_bundle? &&
89
+ lockfile_version
90
+ end
91
+
92
+ def resolve_update_version_from(target)
93
+ requirement = Gem::Requirement.new(target)
94
+ update_candidate = find_latest_matching_spec(requirement)
95
+
96
+ if update_candidate.nil?
97
+ raise InvalidOption, "The `bundle update --bundler` target version (#{target}) does not exist"
98
+ end
99
+
100
+ resolved_version = update_candidate.version
101
+ needs_update = requirement.specific? ? !running?(resolved_version) : running_older_than?(resolved_version)
102
+
103
+ return unless needs_update
104
+
105
+ update_candidate
106
+ end
107
+
108
+ def local_specs
109
+ @local_specs ||= Bundler::Source::Rubygems.new("allow_local" => true).specs.select {|spec| spec.name == "bundler" }
110
+ end
111
+
112
+ def remote_specs
113
+ @remote_specs ||= begin
114
+ source = Bundler::Source::Rubygems.new("remotes" => "https://rubygems.org")
115
+ source.remote!
116
+ source.add_dependency_names("bundler")
117
+ source.specs
118
+ end
119
+ end
120
+
121
+ def find_latest_matching_spec(requirement)
122
+ local_result = find_latest_matching_spec_from_collection(local_specs, requirement)
123
+ return local_result if local_result && requirement.specific?
124
+
125
+ remote_result = find_latest_matching_spec_from_collection(remote_specs, requirement)
126
+ return remote_result if local_result.nil?
127
+
128
+ [local_result, remote_result].max
129
+ end
130
+
131
+ def find_latest_matching_spec_from_collection(specs, requirement)
132
+ specs.sort.reverse_each.find {|spec| requirement.satisfied_by?(spec.version) }
133
+ end
134
+
135
+ def running?(version)
136
+ version == current_version
137
+ end
138
+
139
+ def running_older_than?(version)
140
+ current_version < version
141
+ end
142
+
143
+ def released?(version)
144
+ !version.to_s.end_with?(".dev")
145
+ end
146
+
147
+ def updating?
148
+ "update".start_with?(ARGV.first || " ") && ARGV[1..-1].any? {|a| a.start_with?("--bundler") }
149
+ end
150
+
151
+ def installed?
152
+ Bundler.configure
153
+
154
+ Bundler.rubygems.find_bundler(lockfile_version.to_s)
155
+ end
156
+
157
+ def current_version
158
+ @current_version ||= Gem::Version.new(Bundler::VERSION)
159
+ end
160
+
161
+ def lockfile_version
162
+ return @lockfile_version if defined?(@lockfile_version)
163
+
164
+ parsed_version = Bundler::LockfileParser.bundled_with
165
+ @lockfile_version = parsed_version ? Gem::Version.new(parsed_version) : nil
166
+ end
167
+ end
168
+ end