bundler 1.15.2 → 1.17.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (286) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +302 -0
  3. data/README.md +17 -8
  4. data/bundler.gemspec +25 -9
  5. data/exe/bundle +1 -1
  6. data/exe/bundle_ruby +4 -3
  7. data/lib/bundler/build_metadata.rb +53 -0
  8. data/lib/bundler/capistrano.rb +5 -0
  9. data/lib/bundler/cli/add.rb +15 -6
  10. data/lib/bundler/cli/binstubs.rb +17 -9
  11. data/lib/bundler/cli/cache.rb +5 -4
  12. data/lib/bundler/cli/check.rb +3 -5
  13. data/lib/bundler/cli/clean.rb +5 -6
  14. data/lib/bundler/cli/common.rb +11 -2
  15. data/lib/bundler/cli/config.rb +2 -1
  16. data/lib/bundler/cli/console.rb +2 -1
  17. data/lib/bundler/cli/doctor.rb +48 -1
  18. data/lib/bundler/cli/exec.rb +6 -5
  19. data/lib/bundler/cli/gem.rb +13 -8
  20. data/lib/bundler/cli/info.rb +0 -1
  21. data/lib/bundler/cli/init.rb +18 -6
  22. data/lib/bundler/cli/inject.rb +1 -0
  23. data/lib/bundler/cli/install.rb +64 -61
  24. data/lib/bundler/cli/issue.rb +1 -1
  25. data/lib/bundler/cli/list.rb +58 -0
  26. data/lib/bundler/cli/lock.rb +0 -1
  27. data/lib/bundler/cli/open.rb +2 -2
  28. data/lib/bundler/cli/outdated.rb +20 -9
  29. data/lib/bundler/cli/package.rb +9 -6
  30. data/lib/bundler/cli/platform.rb +1 -0
  31. data/lib/bundler/cli/plugin.rb +1 -0
  32. data/lib/bundler/cli/pristine.rb +20 -6
  33. data/lib/bundler/cli/remove.rb +18 -0
  34. data/lib/bundler/cli/show.rb +0 -1
  35. data/lib/bundler/cli/update.rb +35 -7
  36. data/lib/bundler/cli/viz.rb +1 -0
  37. data/lib/bundler/cli.rb +227 -89
  38. data/lib/bundler/compact_index_client/cache.rb +1 -2
  39. data/lib/bundler/compact_index_client/updater.rb +14 -4
  40. data/lib/bundler/compact_index_client.rb +1 -0
  41. data/lib/bundler/compatibility_guard.rb +14 -0
  42. data/lib/bundler/constants.rb +1 -0
  43. data/lib/bundler/current_ruby.rb +13 -5
  44. data/lib/bundler/definition.rb +192 -139
  45. data/lib/bundler/dep_proxy.rb +3 -1
  46. data/lib/bundler/dependency.rb +9 -9
  47. data/lib/bundler/deployment.rb +1 -1
  48. data/lib/bundler/deprecate.rb +15 -3
  49. data/lib/bundler/dsl.rb +115 -64
  50. data/lib/bundler/endpoint_specification.rb +10 -1
  51. data/lib/bundler/env.rb +90 -29
  52. data/lib/bundler/environment_preserver.rb +27 -6
  53. data/lib/bundler/errors.rb +1 -0
  54. data/lib/bundler/feature_flag.rb +46 -4
  55. data/lib/bundler/fetcher/base.rb +1 -0
  56. data/lib/bundler/fetcher/compact_index.rb +2 -11
  57. data/lib/bundler/fetcher/dependency.rb +2 -1
  58. data/lib/bundler/fetcher/downloader.rb +11 -5
  59. data/lib/bundler/fetcher/index.rb +3 -2
  60. data/lib/bundler/fetcher.rb +18 -11
  61. data/lib/bundler/friendly_errors.rb +6 -1
  62. data/lib/bundler/gem_helper.rb +19 -10
  63. data/lib/bundler/gem_helpers.rb +1 -0
  64. data/lib/bundler/gem_remote_fetcher.rb +1 -0
  65. data/lib/bundler/gem_tasks.rb +1 -0
  66. data/lib/bundler/gem_version_promoter.rb +17 -2
  67. data/lib/bundler/gemdeps.rb +1 -0
  68. data/lib/bundler/graph.rb +1 -0
  69. data/lib/bundler/index.rb +8 -8
  70. data/lib/bundler/injector.rb +192 -30
  71. data/lib/bundler/inline.rb +5 -7
  72. data/lib/bundler/installer/gem_installer.rb +11 -2
  73. data/lib/bundler/installer/parallel_installer.rb +78 -42
  74. data/lib/bundler/installer/standalone.rb +1 -0
  75. data/lib/bundler/installer.rb +138 -53
  76. data/lib/bundler/lazy_specification.rb +3 -2
  77. data/lib/bundler/lockfile_generator.rb +95 -0
  78. data/lib/bundler/lockfile_parser.rb +10 -4
  79. data/lib/bundler/match_platform.rb +1 -0
  80. data/lib/bundler/mirror.rb +8 -5
  81. data/lib/bundler/plugin/api/source.rb +9 -2
  82. data/lib/bundler/plugin/events.rb +61 -0
  83. data/lib/bundler/plugin/index.rb +7 -2
  84. data/lib/bundler/plugin/installer.rb +7 -6
  85. data/lib/bundler/plugin/source_list.rb +7 -8
  86. data/lib/bundler/plugin.rb +13 -5
  87. data/lib/bundler/process_lock.rb +24 -0
  88. data/lib/bundler/psyched_yaml.rb +10 -0
  89. data/lib/bundler/remote_specification.rb +1 -0
  90. data/lib/bundler/resolver/spec_group.rb +106 -0
  91. data/lib/bundler/resolver.rb +158 -195
  92. data/lib/bundler/retry.rb +1 -0
  93. data/lib/bundler/ruby_dsl.rb +1 -0
  94. data/lib/bundler/ruby_version.rb +2 -1
  95. data/lib/bundler/rubygems_ext.rb +5 -4
  96. data/lib/bundler/rubygems_gem_installer.rb +31 -1
  97. data/lib/bundler/rubygems_integration.rb +71 -32
  98. data/lib/bundler/runtime.rb +11 -9
  99. data/lib/bundler/settings/validator.rb +102 -0
  100. data/lib/bundler/settings.rb +200 -77
  101. data/lib/bundler/setup.rb +1 -0
  102. data/lib/bundler/shared_helpers.rb +131 -26
  103. data/lib/bundler/similarity_detector.rb +1 -0
  104. data/lib/bundler/source/gemspec.rb +1 -0
  105. data/lib/bundler/source/git/git_proxy.rb +21 -11
  106. data/lib/bundler/source/git.rb +24 -19
  107. data/lib/bundler/source/metadata.rb +62 -0
  108. data/lib/bundler/source/path/installer.rb +2 -0
  109. data/lib/bundler/source/path.rb +8 -8
  110. data/lib/bundler/source/rubygems/remote.rb +8 -2
  111. data/lib/bundler/source/rubygems.rb +161 -84
  112. data/lib/bundler/source.rb +36 -0
  113. data/lib/bundler/source_list.rb +75 -15
  114. data/lib/bundler/spec_set.rb +10 -5
  115. data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
  116. data/lib/bundler/stub_specification.rb +1 -0
  117. data/lib/bundler/templates/.document +1 -0
  118. data/lib/bundler/templates/Executable +12 -0
  119. data/lib/bundler/templates/Executable.bundler +105 -0
  120. data/lib/bundler/templates/Gemfile +1 -0
  121. data/lib/bundler/templates/gems.rb +8 -0
  122. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  123. data/lib/bundler/templates/newgem/gitignore.tt +0 -1
  124. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
  125. data/lib/bundler/templates/newgem/newgem.gemspec.tt +12 -3
  126. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  127. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +0 -2
  128. data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
  129. data/lib/bundler/ui/rg_proxy.rb +1 -0
  130. data/lib/bundler/ui/shell.rb +17 -4
  131. data/lib/bundler/ui/silent.rb +1 -0
  132. data/lib/bundler/ui.rb +1 -0
  133. data/lib/bundler/uri_credentials_filter.rb +1 -0
  134. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  135. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  136. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  137. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
  138. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  139. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -0
  140. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -0
  141. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -0
  142. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -0
  143. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +1 -0
  144. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -0
  145. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -0
  146. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +15 -4
  147. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -2
  148. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -7
  149. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  150. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
  151. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
  152. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +491 -148
  153. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
  154. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
  155. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
  156. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  157. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -0
  158. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -0
  159. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +9 -1
  160. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +45 -8
  161. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +9 -3
  162. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -3
  163. data/lib/bundler/vendor/thor/lib/thor/base.rb +27 -4
  164. data/lib/bundler/vendor/thor/lib/thor/command.rb +9 -7
  165. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +12 -0
  166. data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  167. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
  168. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +5 -5
  169. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +6 -5
  170. data/lib/bundler/vendor/thor/lib/thor/runner.rb +6 -4
  171. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -9
  172. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  173. data/lib/bundler/vendor/thor/lib/thor.rb +25 -8
  174. data/lib/bundler/vendored_fileutils.rb +9 -0
  175. data/lib/bundler/vendored_molinillo.rb +1 -0
  176. data/lib/bundler/vendored_persistent.rb +35 -0
  177. data/lib/bundler/vendored_thor.rb +1 -0
  178. data/lib/bundler/version.rb +6 -2
  179. data/lib/bundler/version_ranges.rb +1 -0
  180. data/lib/bundler/vlad.rb +5 -0
  181. data/lib/bundler/worker.rb +1 -0
  182. data/lib/bundler/yaml_serializer.rb +3 -3
  183. data/lib/bundler.rb +86 -52
  184. data/man/bundle-add.1 +18 -3
  185. data/man/bundle-add.1.txt +26 -14
  186. data/man/bundle-add.ronn +13 -2
  187. data/man/bundle-binstubs.1 +11 -1
  188. data/man/bundle-binstubs.1.txt +33 -18
  189. data/man/bundle-binstubs.ronn +15 -1
  190. data/man/bundle-check.1 +4 -4
  191. data/man/bundle-check.1.txt +15 -14
  192. data/man/bundle-check.ronn +3 -3
  193. data/man/bundle-clean.1 +1 -1
  194. data/man/bundle-clean.1.txt +10 -10
  195. data/man/bundle-config.1 +129 -29
  196. data/man/bundle-config.1.txt +285 -174
  197. data/man/bundle-config.ronn +167 -88
  198. data/man/bundle-doctor.1 +44 -0
  199. data/man/bundle-doctor.1.txt +44 -0
  200. data/man/bundle-doctor.ronn +33 -0
  201. data/man/bundle-exec.1 +6 -3
  202. data/man/bundle-exec.1.txt +78 -71
  203. data/man/bundle-exec.ronn +10 -3
  204. data/man/bundle-gem.1 +3 -3
  205. data/man/bundle-gem.1.txt +40 -39
  206. data/man/bundle-gem.ronn +2 -1
  207. data/man/bundle-info.1 +1 -1
  208. data/man/bundle-info.1.txt +8 -8
  209. data/man/bundle-init.1 +9 -4
  210. data/man/bundle-init.1.txt +23 -13
  211. data/man/bundle-init.ronn +15 -4
  212. data/man/bundle-inject.1 +4 -4
  213. data/man/bundle-inject.1.txt +10 -10
  214. data/man/bundle-inject.ronn +3 -3
  215. data/man/bundle-install.1 +31 -28
  216. data/man/bundle-install.1.txt +205 -194
  217. data/man/bundle-install.ronn +44 -35
  218. data/man/bundle-list.1 +50 -0
  219. data/man/bundle-list.1.txt +43 -0
  220. data/man/bundle-list.ronn +33 -0
  221. data/man/bundle-lock.1 +1 -1
  222. data/man/bundle-lock.1.txt +47 -47
  223. data/man/bundle-lock.ronn +1 -1
  224. data/man/bundle-open.1 +1 -1
  225. data/man/bundle-open.1.txt +7 -7
  226. data/man/bundle-outdated.1 +7 -3
  227. data/man/bundle-outdated.1.txt +40 -36
  228. data/man/bundle-outdated.ronn +6 -2
  229. data/man/bundle-package.1 +6 -3
  230. data/man/bundle-package.1.txt +44 -39
  231. data/man/bundle-package.ronn +7 -2
  232. data/man/bundle-platform.1 +1 -1
  233. data/man/bundle-platform.1.txt +13 -13
  234. data/man/bundle-pristine.1 +21 -3
  235. data/man/bundle-pristine.1.txt +33 -10
  236. data/man/bundle-pristine.ronn +24 -3
  237. data/man/bundle-remove.1 +31 -0
  238. data/man/bundle-remove.1.txt +34 -0
  239. data/man/bundle-remove.ronn +23 -0
  240. data/man/bundle-show.1 +3 -3
  241. data/man/bundle-show.1.txt +14 -12
  242. data/man/bundle-show.ronn +3 -2
  243. data/man/bundle-update.1 +13 -9
  244. data/man/bundle-update.1.txt +133 -130
  245. data/man/bundle-update.ronn +21 -17
  246. data/man/bundle-viz.1 +7 -7
  247. data/man/bundle-viz.1.txt +17 -15
  248. data/man/bundle-viz.ronn +6 -6
  249. data/man/bundle.1 +31 -23
  250. data/man/bundle.1.txt +63 -57
  251. data/man/bundle.ronn +35 -29
  252. data/man/gemfile.5 +44 -8
  253. data/man/gemfile.5.ronn +54 -8
  254. data/man/gemfile.5.txt +218 -165
  255. data/man/index.txt +25 -15
  256. metadata +36 -36
  257. data/.codeclimate.yml +0 -25
  258. data/.gitignore +0 -18
  259. data/.rspec +0 -3
  260. data/.rubocop.yml +0 -131
  261. data/.rubocop_todo.yml +0 -418
  262. data/.travis.yml +0 -122
  263. data/CODE_OF_CONDUCT.md +0 -42
  264. data/CONTRIBUTING.md +0 -17
  265. data/Rakefile +0 -338
  266. data/bin/rake +0 -19
  267. data/bin/rspec +0 -15
  268. data/bin/rubocop +0 -17
  269. data/bin/with_rubygems +0 -39
  270. data/doc/README.md +0 -30
  271. data/doc/TROUBLESHOOTING.md +0 -64
  272. data/doc/contributing/BUG_TRIAGE.md +0 -36
  273. data/doc/contributing/COMMUNITY.md +0 -13
  274. data/doc/contributing/GETTING_HELP.md +0 -11
  275. data/doc/contributing/HOW_YOU_CAN_HELP.md +0 -27
  276. data/doc/contributing/ISSUES.md +0 -51
  277. data/doc/contributing/README.md +0 -38
  278. data/doc/development/NEW_FEATURES.md +0 -10
  279. data/doc/development/PULL_REQUESTS.md +0 -40
  280. data/doc/development/README.md +0 -19
  281. data/doc/development/RELEASING.md +0 -9
  282. data/doc/development/SETUP.md +0 -27
  283. data/doc/documentation/README.md +0 -29
  284. data/doc/documentation/VISION.md +0 -26
  285. data/doc/documentation/WRITING.md +0 -54
  286. data/task/release.rake +0 -116
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require "bundler/compatibility_guard"
4
+
2
5
  require "pathname"
3
6
  require "rubygems"
4
7
 
8
+ require "bundler/version"
5
9
  require "bundler/constants"
6
10
  require "bundler/rubygems_integration"
7
11
  require "bundler/current_ruby"
@@ -19,10 +23,16 @@ end
19
23
 
20
24
  module Bundler
21
25
  module SharedHelpers
22
- def default_gemfile
26
+ def root
23
27
  gemfile = find_gemfile
24
28
  raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
25
- Pathname.new(gemfile).untaint
29
+ Pathname.new(gemfile).untaint.expand_path.parent
30
+ end
31
+
32
+ def default_gemfile
33
+ gemfile = find_gemfile(:order_matters)
34
+ raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
35
+ Pathname.new(gemfile).untaint.expand_path
26
36
  end
27
37
 
28
38
  def default_lockfile
@@ -63,7 +73,7 @@ module Bundler
63
73
  end
64
74
 
65
75
  def with_clean_git_env(&block)
66
- keys = %w(GIT_DIR GIT_WORK_TREE)
76
+ keys = %w[GIT_DIR GIT_WORK_TREE]
67
77
  old_env = keys.inject({}) do |h, k|
68
78
  h.update(k => ENV[k])
69
79
  end
@@ -129,20 +139,34 @@ module Bundler
129
139
  namespace.const_get(constant_name)
130
140
  end
131
141
 
132
- def major_deprecation(message)
142
+ def major_deprecation(major_version, message)
143
+ if Bundler.bundler_major_version >= major_version
144
+ require "bundler/errors"
145
+ raise DeprecatedError, "[REMOVED FROM #{major_version}.0] #{message}"
146
+ end
147
+
133
148
  return unless prints_major_deprecations?
134
149
  @major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true)
135
150
  ui = Bundler.ui.is_a?(@major_deprecation_ui.class) ? Bundler.ui : @major_deprecation_ui
136
- ui.warn("[DEPRECATED FOR #{Bundler::VERSION.split(".").first.to_i + 1}.0] #{message}")
151
+ ui.warn("[DEPRECATED FOR #{major_version}.0] #{message}")
137
152
  end
138
153
 
139
154
  def print_major_deprecations!
140
- deprecate_gemfile(find_gemfile) if find_gemfile == find_file("Gemfile")
155
+ multiple_gemfiles = search_up(".") do |dir|
156
+ gemfiles = gemfile_names.select {|gf| File.file? File.expand_path(gf, dir) }
157
+ next if gemfiles.empty?
158
+ break false if gemfiles.size == 1
159
+ end
160
+ if multiple_gemfiles && Bundler.bundler_major_version == 1
161
+ Bundler::SharedHelpers.major_deprecation 2, \
162
+ "gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock."
163
+ end
164
+
141
165
  if RUBY_VERSION < "2"
142
- major_deprecation("Bundler will only support ruby >= 2.0, you are running #{RUBY_VERSION}")
166
+ major_deprecation(2, "Bundler will only support ruby >= 2.0, you are running #{RUBY_VERSION}")
143
167
  end
144
168
  return if Bundler.rubygems.provides?(">= 2")
145
- major_deprecation("Bundler will only support rubygems >= 2.0, you are running #{Bundler.rubygems.version}")
169
+ major_deprecation(2, "Bundler will only support rubygems >= 2.0, you are running #{Bundler.rubygems.version}")
146
170
  end
147
171
 
148
172
  def trap(signal, override = false, &block)
@@ -170,12 +194,65 @@ module Bundler
170
194
  "\nEither installing with `--full-index` or running `bundle update #{spec.name}` should fix the problem."
171
195
  end
172
196
 
197
+ def pretty_dependency(dep, print_source = false)
198
+ msg = String.new(dep.name)
199
+ msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
200
+
201
+ if dep.is_a?(Bundler::Dependency)
202
+ platform_string = dep.platforms.join(", ")
203
+ msg << " " << platform_string if !platform_string.empty? && platform_string != Gem::Platform::RUBY
204
+ end
205
+
206
+ msg << " from the `#{dep.source}` source" if print_source && dep.source
207
+ msg
208
+ end
209
+
210
+ def md5_available?
211
+ return @md5_available if defined?(@md5_available)
212
+ @md5_available = begin
213
+ require "openssl"
214
+ OpenSSL::Digest::MD5.digest("")
215
+ true
216
+ rescue LoadError
217
+ true
218
+ rescue OpenSSL::Digest::DigestError
219
+ false
220
+ end
221
+ end
222
+
223
+ def digest(name)
224
+ require "digest"
225
+ Digest(name)
226
+ end
227
+
228
+ def write_to_gemfile(gemfile_path, contents)
229
+ filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } }
230
+ end
231
+
173
232
  private
174
233
 
175
- def find_gemfile
234
+ def validate_bundle_path
235
+ path_separator = Bundler.rubygems.path_separator
236
+ return unless Bundler.bundle_path.to_s.split(path_separator).size > 1
237
+ message = "Your bundle path contains text matching #{path_separator.inspect}, " \
238
+ "which is the path separator for your system. Bundler cannot " \
239
+ "function correctly when the Bundle path contains the " \
240
+ "system's PATH separator. Please change your " \
241
+ "bundle path to not match #{path_separator.inspect}." \
242
+ "\nYour current bundle path is '#{Bundler.bundle_path}'."
243
+ raise Bundler::PathError, message
244
+ end
245
+
246
+ def find_gemfile(order_matters = false)
176
247
  given = ENV["BUNDLE_GEMFILE"]
177
248
  return given if given && !given.empty?
178
- find_file("Gemfile", "gems.rb")
249
+ names = gemfile_names
250
+ names.reverse! if order_matters && Bundler.feature_flag.prefer_gems_rb?
251
+ find_file(*names)
252
+ end
253
+
254
+ def gemfile_names
255
+ ["Gemfile", "gems.rb"]
179
256
  end
180
257
 
181
258
  def find_file(*names)
@@ -197,7 +274,15 @@ module Bundler
197
274
  until !File.directory?(current) || current == previous
198
275
  if ENV["BUNDLE_SPEC_RUN"]
199
276
  # avoid stepping above the tmp directory when testing
200
- return nil if File.file?(File.join(current, "bundler.gemspec"))
277
+ gemspec = if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]
278
+ # for Ruby Core
279
+ "lib/bundler.gemspec"
280
+ else
281
+ "bundler.gemspec"
282
+ end
283
+
284
+ # avoid stepping above the tmp directory when testing
285
+ return nil if File.file?(File.join(current, gemspec))
201
286
  end
202
287
 
203
288
  names.each do |name|
@@ -209,39 +294,58 @@ module Bundler
209
294
  end
210
295
  end
211
296
 
297
+ def set_env(key, value)
298
+ raise ArgumentError, "new key #{key}" unless EnvironmentPreserver::BUNDLER_KEYS.include?(key)
299
+ orig_key = "#{EnvironmentPreserver::BUNDLER_PREFIX}#{key}"
300
+ orig = ENV[key]
301
+ orig ||= EnvironmentPreserver::INTENTIONALLY_NIL
302
+ ENV[orig_key] ||= orig
303
+
304
+ ENV[key] = value
305
+ end
306
+ public :set_env
307
+
212
308
  def set_bundle_variables
213
309
  begin
214
- ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
310
+ exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
311
+ unless File.exist?(exe_file)
312
+ exe_file = File.expand_path("../../../exe/bundle", __FILE__)
313
+ end
314
+ Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
215
315
  rescue Gem::GemNotFoundException
216
- ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../exe/bundle", __FILE__)
316
+ exe_file = File.expand_path("../../../exe/bundle", __FILE__)
317
+ # for Ruby core repository
318
+ exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file)
319
+ Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
217
320
  end
218
321
 
219
322
  # Set BUNDLE_GEMFILE
220
- ENV["BUNDLE_GEMFILE"] = find_gemfile.to_s
221
- ENV["BUNDLER_VERSION"] = Bundler::VERSION
323
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile(:order_matters).to_s
324
+ Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
222
325
  end
223
326
 
224
327
  def set_path
328
+ validate_bundle_path
225
329
  paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
226
330
  paths.unshift "#{Bundler.bundle_path}/bin"
227
- ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
331
+ Bundler::SharedHelpers.set_env "PATH", paths.uniq.join(File::PATH_SEPARATOR)
228
332
  end
229
333
 
230
334
  def set_rubyopt
231
335
  rubyopt = [ENV["RUBYOPT"]].compact
232
336
  return if !rubyopt.empty? && rubyopt.first =~ %r{-rbundler/setup}
233
337
  rubyopt.unshift %(-rbundler/setup)
234
- ENV["RUBYOPT"] = rubyopt.join(" ")
338
+ Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
235
339
  end
236
340
 
237
341
  def set_rubylib
238
342
  rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR)
239
343
  rubylib.unshift bundler_ruby_lib
240
- ENV["RUBYLIB"] = rubylib.uniq.join(File::PATH_SEPARATOR)
344
+ Bundler::SharedHelpers.set_env "RUBYLIB", rubylib.uniq.join(File::PATH_SEPARATOR)
241
345
  end
242
346
 
243
347
  def bundler_ruby_lib
244
- File.expand_path("../..", __FILE__)
348
+ resolve_path File.expand_path("../..", __FILE__)
245
349
  end
246
350
 
247
351
  def clean_load_path
@@ -253,12 +357,19 @@ module Bundler
253
357
  loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
254
358
 
255
359
  $LOAD_PATH.reject! do |p|
256
- next if File.expand_path(p).start_with?(bundler_lib)
360
+ next if resolve_path(p).start_with?(bundler_lib)
257
361
  loaded_gem_paths.delete(p)
258
362
  end
259
363
  $LOAD_PATH.uniq!
260
364
  end
261
365
 
366
+ def resolve_path(path)
367
+ expanded = File.expand_path(path)
368
+ return expanded unless File.respond_to?(:realpath) && File.exist?(expanded)
369
+
370
+ File.realpath(expanded)
371
+ end
372
+
262
373
  def prints_major_deprecations?
263
374
  require "bundler"
264
375
  deprecation_release = Bundler::VERSION.split(".").drop(1).include?("99")
@@ -268,12 +379,6 @@ module Bundler
268
379
  true
269
380
  end
270
381
 
271
- def deprecate_gemfile(gemfile)
272
- return unless gemfile && File.basename(gemfile) == "Gemfile"
273
- Bundler::SharedHelpers.major_deprecation \
274
- "gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock."
275
- end
276
-
277
382
  extend self
278
383
  end
279
384
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class SimilarityDetector
4
5
  SimilarityScore = Struct.new(:string, :distance)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class Source
4
5
  class Gemspec < Path
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "shellwords"
3
4
  require "tempfile"
4
5
  module Bundler
@@ -62,7 +63,7 @@ module Bundler
62
63
  begin
63
64
  @revision ||= find_local_revision
64
65
  rescue GitCommandError
65
- raise MissingGitRevisionError.new(ref, uri)
66
+ raise MissingGitRevisionError.new(ref, URICredentialsFilter.credential_filtered_uri(uri))
66
67
  end
67
68
 
68
69
  @revision
@@ -90,18 +91,21 @@ module Bundler
90
91
  end
91
92
 
92
93
  def checkout
93
- if path.exist?
94
- return if has_revision_cached?
95
- Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
96
- in_path do
97
- git_retry %(fetch --force --quiet --tags #{uri_escaped_with_configured_credentials} "refs/heads/*:refs/heads/*")
98
- end
99
- else
100
- Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
94
+ return if path.exist? && has_revision_cached?
95
+ extra_ref = "#{Shellwords.shellescape(ref)}:#{Shellwords.shellescape(ref)}" if ref && ref.start_with?("refs/")
96
+
97
+ Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}"
98
+
99
+ unless path.exist?
101
100
  SharedHelpers.filesystem_access(path.dirname) do |p|
102
101
  FileUtils.mkdir_p(p)
103
102
  end
104
103
  git_retry %(clone #{uri_escaped_with_configured_credentials} "#{path}" --bare --no-hardlinks --quiet)
104
+ return unless extra_ref
105
+ end
106
+
107
+ in_path do
108
+ git_retry %(fetch --force --quiet --tags #{uri_escaped_with_configured_credentials} "refs/heads/*:refs/heads/*" #{extra_ref})
105
109
  end
106
110
  end
107
111
 
@@ -127,7 +131,12 @@ module Bundler
127
131
  # method 2
128
132
  SharedHelpers.chdir(destination) do
129
133
  git_retry %(fetch --force --quiet --tags "#{path}")
130
- git "reset --hard #{@revision}"
134
+
135
+ begin
136
+ git "reset --hard #{@revision}"
137
+ rescue GitCommandError
138
+ raise MissingGitRevisionError.new(@revision, URICredentialsFilter.credential_filtered_uri(uri))
139
+ end
131
140
 
132
141
  if submodules
133
142
  git_retry "submodule update --init --recursive"
@@ -149,7 +158,7 @@ module Bundler
149
158
  end
150
159
 
151
160
  def git_retry(command)
152
- Bundler::Retry.new("`git #{command}`", GitNotAllowedError).attempts do
161
+ Bundler::Retry.new("`git #{URICredentialsFilter.credential_filtered_string(command, uri)}`", GitNotAllowedError).attempts do
153
162
  git(command)
154
163
  end
155
164
  end
@@ -217,6 +226,7 @@ module Bundler
217
226
 
218
227
  def in_path(&blk)
219
228
  checkout unless path.exist?
229
+ _ = URICredentialsFilter # load it before we chdir
220
230
  SharedHelpers.chdir(path, &blk)
221
231
  end
222
232
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
- require "fileutils"
2
+
3
+ require "bundler/vendored_fileutils"
3
4
  require "uri"
4
- require "digest/sha1"
5
5
 
6
6
  module Bundler
7
7
  class Source
@@ -18,9 +18,10 @@ module Bundler
18
18
  @allow_remote = false
19
19
 
20
20
  # Stringify options that could be set as symbols
21
- %w(ref branch tag revision).each {|k| options[k] = options[k].to_s if options[k] }
21
+ %w[ref branch tag revision].each {|k| options[k] = options[k].to_s if options[k] }
22
22
 
23
23
  @uri = options["uri"] || ""
24
+ @safe_uri = URICredentialsFilter.credential_filtered_uri(@uri)
24
25
  @branch = options["branch"]
25
26
  @ref = options["ref"] || options["branch"] || options["tag"] || "master"
26
27
  @submodules = options["submodules"]
@@ -39,7 +40,7 @@ module Bundler
39
40
  out = String.new("GIT\n")
40
41
  out << " remote: #{@uri}\n"
41
42
  out << " revision: #{revision}\n"
42
- %w(ref branch tag submodules).each do |opt|
43
+ %w[ref branch tag submodules].each do |opt|
43
44
  out << " #{opt}: #{options[opt]}\n" if options[opt]
44
45
  end
45
46
  out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
@@ -77,7 +78,7 @@ module Bundler
77
78
  nil
78
79
  end
79
80
 
80
- "#{uri} (at #{at}#{rev})"
81
+ "#{@safe_uri} (at #{at}#{rev})"
81
82
  end
82
83
 
83
84
  def name
@@ -169,15 +170,13 @@ module Bundler
169
170
  def install(spec, options = {})
170
171
  force = options[:force]
171
172
 
172
- Bundler.ui.info "Using #{version_message(spec)} from #{self}"
173
+ print_using_message "Using #{version_message(spec)} from #{self}"
173
174
 
174
- if requires_checkout? && !@copied && !force
175
+ if (requires_checkout? && !@copied) || force
175
176
  Bundler.ui.debug " * Checking out revision: #{ref}"
176
177
  git_proxy.copy_to(install_path, submodules)
177
178
  serialize_gemspecs_in(install_path)
178
179
  @copied = true
179
- elsif force
180
- git_proxy.copy_to(install_path, submodules)
181
180
  end
182
181
 
183
182
  generate_bin_options = { :disable_extensions => !Bundler.rubygems.spec_missing_extensions?(spec), :build_args => options[:build_args] }
@@ -188,7 +187,7 @@ module Bundler
188
187
 
189
188
  def cache(spec, custom_path = nil)
190
189
  app_cache_path = app_cache_path(custom_path)
191
- return unless Bundler.settings[:cache_all]
190
+ return unless Bundler.feature_flag.cache_all?
192
191
  return if path == app_cache_path
193
192
  cached!
194
193
  FileUtils.rm_rf(app_cache_path)
@@ -210,13 +209,11 @@ module Bundler
210
209
  # When using local git repos, this is set to the local repo.
211
210
  def cache_path
212
211
  @cache_path ||= begin
213
- git_scope = "#{base_name}-#{uri_hash}"
214
-
215
- if Bundler.requires_sudo?
216
- Bundler.user_bundle_path.join("cache/git", git_scope)
212
+ if Bundler.requires_sudo? || Bundler.feature_flag.global_gem_cache?
213
+ Bundler.user_cache
217
214
  else
218
- Bundler.cache.join("git", git_scope)
219
- end
215
+ Bundler.bundle_path.join("cache", "bundler")
216
+ end.join("git", git_scope)
220
217
  end
221
218
  end
222
219
 
@@ -287,7 +284,7 @@ module Bundler
287
284
  # If there is no URI scheme, assume it is an ssh/git URI
288
285
  input = uri
289
286
  end
290
- Digest::SHA1.hexdigest(input)
287
+ SharedHelpers.digest(:SHA1).hexdigest(input)
291
288
  end
292
289
 
293
290
  def cached_revision
@@ -304,9 +301,9 @@ module Bundler
304
301
 
305
302
  def fetch
306
303
  git_proxy.checkout
307
- rescue GitError
304
+ rescue GitError => e
308
305
  raise unless Bundler.feature_flag.allow_offline_install?
309
- Bundler.ui.warn "Using cached git data because of network errors"
306
+ Bundler.ui.warn "Using cached git data because of network errors:\n#{e}"
310
307
  end
311
308
 
312
309
  # no-op, since we validate when re-serializing the gemspec
@@ -319,6 +316,14 @@ module Bundler
319
316
  StubSpecification.from_stub(stub)
320
317
  end
321
318
  end
319
+
320
+ def git_scope
321
+ "#{base_name}-#{uri_hash}"
322
+ end
323
+
324
+ def extension_cache_slug(_)
325
+ extension_dir_name
326
+ end
322
327
  end
323
328
  end
324
329
  end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class Source
5
+ class Metadata < Source
6
+ def specs
7
+ @specs ||= Index.build do |idx|
8
+ idx << Gem::Specification.new("ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
9
+ idx << Gem::Specification.new("rubygems\0", Gem::VERSION)
10
+
11
+ idx << Gem::Specification.new do |s|
12
+ s.name = "bundler"
13
+ s.version = VERSION
14
+ s.platform = Gem::Platform::RUBY
15
+ s.source = self
16
+ s.authors = ["bundler team"]
17
+ s.bindir = "exe"
18
+ s.executables = %w[bundle]
19
+ # can't point to the actual gemspec or else the require paths will be wrong
20
+ s.loaded_from = File.expand_path("..", __FILE__)
21
+ end
22
+
23
+ if local_spec = Bundler.rubygems.find_name("bundler").find {|s| s.version.to_s == VERSION }
24
+ idx << local_spec
25
+ end
26
+
27
+ idx.each {|s| s.source = self }
28
+ end
29
+ end
30
+
31
+ def cached!; end
32
+
33
+ def remote!; end
34
+
35
+ def options
36
+ {}
37
+ end
38
+
39
+ def install(spec, _opts = {})
40
+ print_using_message "Using #{version_message(spec)}"
41
+ nil
42
+ end
43
+
44
+ def to_s
45
+ "the local ruby installation"
46
+ end
47
+
48
+ def ==(other)
49
+ self.class == other.class
50
+ end
51
+ alias_method :eql?, :==
52
+
53
+ def hash
54
+ self.class.hash
55
+ end
56
+
57
+ def version_message(spec)
58
+ "#{spec.name} #{spec.version}"
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class Source
4
5
  class Path
@@ -6,6 +7,7 @@ module Bundler
6
7
  attr_reader :spec
7
8
 
8
9
  def initialize(spec, options = {})
10
+ @options = options
9
11
  @spec = spec
10
12
  @gem_dir = Bundler.rubygems.path(spec.full_gem_path)
11
13
  @wrappers = true
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class Source
4
5
  class Path < Source
@@ -35,10 +36,12 @@ module Bundler
35
36
  end
36
37
 
37
38
  def remote!
39
+ @local_specs = nil
38
40
  @allow_remote = true
39
41
  end
40
42
 
41
43
  def cached!
44
+ @local_specs = nil
42
45
  @allow_cached = true
43
46
  end
44
47
 
@@ -74,14 +77,14 @@ module Bundler
74
77
  end
75
78
 
76
79
  def install(spec, options = {})
77
- Bundler.ui.info "Using #{version_message(spec)} from #{self}"
80
+ print_using_message "Using #{version_message(spec)} from #{self}"
78
81
  generate_bin(spec, :disable_extensions => true)
79
82
  nil # no post-install message
80
83
  end
81
84
 
82
85
  def cache(spec, custom_path = nil)
83
86
  app_cache_path = app_cache_path(custom_path)
84
- return unless Bundler.settings[:cache_all]
87
+ return unless Bundler.feature_flag.cache_all?
85
88
  return if expand(@original_path).to_s.index(root_path.to_s + "/") == 0
86
89
 
87
90
  unless @original_path.exist?
@@ -113,10 +116,6 @@ module Bundler
113
116
  Bundler.root
114
117
  end
115
118
 
116
- def is_a_path?
117
- instance_of?(Path)
118
- end
119
-
120
119
  def expanded_original_path
121
120
  @expanded_original_path ||= expand(original_path)
122
121
  end
@@ -228,7 +227,8 @@ module Bundler
228
227
  spec,
229
228
  :env_shebang => false,
230
229
  :disable_extensions => options[:disable_extensions],
231
- :build_args => options[:build_args]
230
+ :build_args => options[:build_args],
231
+ :bundler_extension_cache_path => extension_cache_path(spec)
232
232
  )
233
233
  installer.post_install
234
234
  rescue Gem::InvalidSpecificationException => e
@@ -242,7 +242,7 @@ module Bundler
242
242
  "to modify their .gemspec so it can work with `gem build`."
243
243
  end
244
244
 
245
- Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}"
245
+ Bundler.ui.warn "The validation message from RubyGems was:\n #{e.message}"
246
246
  end
247
247
  end
248
248
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class Source
4
5
  class Rubygems
@@ -20,10 +21,15 @@ module Bundler
20
21
  #
21
22
  def cache_slug
22
23
  @cache_slug ||= begin
24
+ return nil unless SharedHelpers.md5_available?
25
+
23
26
  cache_uri = original_uri || uri
24
27
 
25
- uri_parts = [cache_uri.host, cache_uri.user, cache_uri.port, cache_uri.path]
26
- uri_digest = Digest::MD5.hexdigest(uri_parts.compact.join("."))
28
+ # URI::File of Ruby 2.6 returns empty string when given "file://".
29
+ host = defined?(URI::File) && cache_uri.is_a?(URI::File) ? nil : cache_uri.host
30
+
31
+ uri_parts = [host, cache_uri.user, cache_uri.port, cache_uri.path]
32
+ uri_digest = SharedHelpers.digest(:MD5).hexdigest(uri_parts.compact.join("."))
27
33
 
28
34
  uri_parts[-1] = uri_digest
29
35
  uri_parts.compact.join(".")