bundler 1.15.4 → 1.16.0.pre.1

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 (251) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +43 -0
  3. data/README.md +12 -7
  4. data/exe/bundle +1 -1
  5. data/exe/bundle_ruby +4 -3
  6. data/lib/bundler.rb +47 -37
  7. data/lib/bundler/build_metadata.rb +38 -0
  8. data/lib/bundler/capistrano.rb +5 -0
  9. data/lib/bundler/cli.rb +155 -67
  10. data/lib/bundler/cli/add.rb +0 -1
  11. data/lib/bundler/cli/binstubs.rb +9 -7
  12. data/lib/bundler/cli/cache.rb +5 -4
  13. data/lib/bundler/cli/check.rb +3 -5
  14. data/lib/bundler/cli/clean.rb +5 -6
  15. data/lib/bundler/cli/common.rb +11 -2
  16. data/lib/bundler/cli/config.rb +2 -1
  17. data/lib/bundler/cli/console.rb +2 -1
  18. data/lib/bundler/cli/doctor.rb +1 -0
  19. data/lib/bundler/cli/exec.rb +2 -1
  20. data/lib/bundler/cli/gem.rb +3 -2
  21. data/lib/bundler/cli/info.rb +0 -1
  22. data/lib/bundler/cli/init.rb +17 -6
  23. data/lib/bundler/cli/inject.rb +1 -0
  24. data/lib/bundler/cli/install.rb +61 -61
  25. data/lib/bundler/cli/issue.rb +1 -1
  26. data/lib/bundler/cli/list.rb +22 -0
  27. data/lib/bundler/cli/lock.rb +0 -1
  28. data/lib/bundler/cli/open.rb +2 -2
  29. data/lib/bundler/cli/outdated.rb +13 -8
  30. data/lib/bundler/cli/package.rb +9 -6
  31. data/lib/bundler/cli/platform.rb +1 -0
  32. data/lib/bundler/cli/plugin.rb +1 -0
  33. data/lib/bundler/cli/pristine.rb +9 -2
  34. data/lib/bundler/cli/show.rb +0 -1
  35. data/lib/bundler/cli/update.rb +31 -5
  36. data/lib/bundler/cli/viz.rb +1 -0
  37. data/lib/bundler/compact_index_client.rb +1 -0
  38. data/lib/bundler/compact_index_client/cache.rb +1 -0
  39. data/lib/bundler/compact_index_client/updater.rb +3 -2
  40. data/lib/bundler/compatibility_guard.rb +14 -0
  41. data/lib/bundler/constants.rb +1 -0
  42. data/lib/bundler/current_ruby.rb +5 -4
  43. data/lib/bundler/definition.rb +140 -95
  44. data/lib/bundler/dep_proxy.rb +2 -0
  45. data/lib/bundler/dependency.rb +6 -7
  46. data/lib/bundler/deployment.rb +1 -1
  47. data/lib/bundler/deprecate.rb +1 -0
  48. data/lib/bundler/dsl.rb +97 -62
  49. data/lib/bundler/endpoint_specification.rb +9 -0
  50. data/lib/bundler/env.rb +63 -27
  51. data/lib/bundler/environment_preserver.rb +26 -6
  52. data/lib/bundler/errors.rb +1 -0
  53. data/lib/bundler/feature_flag.rb +39 -4
  54. data/lib/bundler/fetcher.rb +15 -8
  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 +1 -0
  58. data/lib/bundler/fetcher/downloader.rb +1 -0
  59. data/lib/bundler/fetcher/index.rb +1 -0
  60. data/lib/bundler/friendly_errors.rb +2 -1
  61. data/lib/bundler/gem_helper.rb +14 -9
  62. data/lib/bundler/gem_helpers.rb +1 -0
  63. data/lib/bundler/gem_remote_fetcher.rb +1 -0
  64. data/lib/bundler/gem_tasks.rb +1 -0
  65. data/lib/bundler/gem_version_promoter.rb +1 -0
  66. data/lib/bundler/gemdeps.rb +1 -0
  67. data/lib/bundler/graph.rb +1 -0
  68. data/lib/bundler/index.rb +15 -8
  69. data/lib/bundler/injector.rb +25 -22
  70. data/lib/bundler/inline.rb +5 -7
  71. data/lib/bundler/installer.rb +93 -45
  72. data/lib/bundler/installer/gem_installer.rb +2 -0
  73. data/lib/bundler/installer/parallel_installer.rb +73 -42
  74. data/lib/bundler/installer/standalone.rb +1 -0
  75. data/lib/bundler/lazy_specification.rb +2 -1
  76. data/lib/bundler/lockfile_generator.rb +95 -0
  77. data/lib/bundler/lockfile_parser.rb +10 -4
  78. data/lib/bundler/match_platform.rb +1 -0
  79. data/lib/bundler/mirror.rb +6 -3
  80. data/lib/bundler/plugin.rb +1 -0
  81. data/lib/bundler/plugin/api/source.rb +8 -0
  82. data/lib/bundler/plugin/installer.rb +7 -6
  83. data/lib/bundler/plugin/source_list.rb +7 -8
  84. data/lib/bundler/process_lock.rb +24 -0
  85. data/lib/bundler/psyched_yaml.rb +1 -0
  86. data/lib/bundler/remote_specification.rb +1 -0
  87. data/lib/bundler/resolver.rb +138 -191
  88. data/lib/bundler/resolver/spec_group.rb +111 -0
  89. data/lib/bundler/retry.rb +1 -0
  90. data/lib/bundler/ruby_dsl.rb +1 -0
  91. data/lib/bundler/ruby_version.rb +1 -0
  92. data/lib/bundler/rubygems_ext.rb +5 -4
  93. data/lib/bundler/rubygems_gem_installer.rb +23 -0
  94. data/lib/bundler/rubygems_integration.rb +56 -27
  95. data/lib/bundler/runtime.rb +3 -5
  96. data/lib/bundler/settings.rb +177 -76
  97. data/lib/bundler/settings/validator.rb +79 -0
  98. data/lib/bundler/setup.rb +1 -0
  99. data/lib/bundler/shared_helpers.rb +86 -26
  100. data/lib/bundler/similarity_detector.rb +1 -0
  101. data/lib/bundler/source.rb +32 -0
  102. data/lib/bundler/source/gemspec.rb +1 -0
  103. data/lib/bundler/source/git.rb +21 -16
  104. data/lib/bundler/source/git/git_proxy.rb +14 -10
  105. data/lib/bundler/source/metadata.rb +63 -0
  106. data/lib/bundler/source/path.rb +8 -8
  107. data/lib/bundler/source/path/installer.rb +2 -0
  108. data/lib/bundler/source/rubygems.rb +131 -84
  109. data/lib/bundler/source/rubygems/remote.rb +3 -0
  110. data/lib/bundler/source_list.rb +75 -15
  111. data/lib/bundler/spec_set.rb +2 -1
  112. data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
  113. data/lib/bundler/stub_specification.rb +1 -0
  114. data/lib/bundler/templates/Executable +4 -0
  115. data/lib/bundler/templates/Executable.bundler +105 -0
  116. data/lib/bundler/templates/Gemfile +1 -0
  117. data/lib/bundler/templates/gems.rb +8 -0
  118. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  119. data/lib/bundler/templates/newgem/gitignore.tt +0 -1
  120. data/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -1
  121. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  122. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +0 -2
  123. data/lib/bundler/ui.rb +1 -0
  124. data/lib/bundler/ui/rg_proxy.rb +1 -0
  125. data/lib/bundler/ui/shell.rb +15 -4
  126. data/lib/bundler/ui/silent.rb +1 -0
  127. data/lib/bundler/uri_credentials_filter.rb +1 -0
  128. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  129. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
  130. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  131. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  132. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
  133. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -2
  134. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  135. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -0
  136. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -0
  137. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -0
  138. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -0
  139. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +1 -0
  140. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -0
  141. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -0
  142. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +3 -2
  143. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +69 -6
  144. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  145. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
  146. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
  147. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +487 -148
  148. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
  149. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
  150. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  151. data/lib/bundler/vendored_fileutils.rb +9 -0
  152. data/lib/bundler/vendored_molinillo.rb +1 -0
  153. data/lib/bundler/vendored_persistent.rb +34 -0
  154. data/lib/bundler/vendored_thor.rb +1 -0
  155. data/lib/bundler/version.rb +6 -2
  156. data/lib/bundler/version_ranges.rb +1 -0
  157. data/lib/bundler/vlad.rb +5 -0
  158. data/lib/bundler/worker.rb +1 -0
  159. data/lib/bundler/yaml_serializer.rb +3 -3
  160. data/man/bundle-add.1 +43 -0
  161. data/man/bundle-add.1.txt +40 -0
  162. data/man/bundle-binstubs.1 +40 -0
  163. data/man/bundle-binstubs.1.txt +48 -0
  164. data/man/bundle-binstubs.ronn +14 -0
  165. data/man/bundle-check.1 +31 -0
  166. data/man/bundle-check.1.txt +32 -0
  167. data/man/bundle-clean.1 +24 -0
  168. data/man/bundle-clean.1.txt +26 -0
  169. data/man/bundle-config.1 +455 -0
  170. data/man/bundle-config.1.txt +491 -0
  171. data/man/bundle-config.ronn +133 -79
  172. data/man/bundle-exec.1 +165 -0
  173. data/man/bundle-exec.1.txt +178 -0
  174. data/man/bundle-exec.ronn +7 -0
  175. data/man/bundle-gem.1 +80 -0
  176. data/man/bundle-gem.1.txt +91 -0
  177. data/man/bundle-gem.ronn +2 -1
  178. data/man/bundle-info.1 +20 -0
  179. data/man/bundle-info.1.txt +21 -0
  180. data/man/bundle-init.1 +20 -0
  181. data/man/bundle-init.1.txt +24 -0
  182. data/man/bundle-inject.1 +33 -0
  183. data/man/bundle-inject.1.txt +32 -0
  184. data/man/bundle-install.1 +305 -0
  185. data/man/bundle-install.1.txt +385 -0
  186. data/man/bundle-install.ronn +32 -32
  187. data/man/bundle-list.1 +20 -0
  188. data/man/bundle-list.1.txt +21 -0
  189. data/man/bundle-list.ronn +15 -0
  190. data/man/bundle-lock.1 +84 -0
  191. data/man/bundle-lock.1.txt +93 -0
  192. data/man/bundle-open.1 +32 -0
  193. data/man/bundle-open.1.txt +29 -0
  194. data/man/bundle-outdated.1 +151 -0
  195. data/man/bundle-outdated.1.txt +127 -0
  196. data/man/bundle-outdated.ronn +1 -1
  197. data/man/bundle-package.1 +55 -0
  198. data/man/bundle-package.1.txt +79 -0
  199. data/man/bundle-package.ronn +5 -0
  200. data/man/bundle-platform.1 +61 -0
  201. data/man/bundle-platform.1.txt +57 -0
  202. data/man/bundle-pristine.1 +34 -0
  203. data/man/bundle-pristine.1.txt +44 -0
  204. data/man/bundle-pristine.ronn +24 -3
  205. data/man/bundle-show.1 +23 -0
  206. data/man/bundle-show.1.txt +25 -0
  207. data/man/bundle-update.1 +390 -0
  208. data/man/bundle-update.1.txt +386 -0
  209. data/man/bundle-update.ronn +2 -2
  210. data/man/bundle-viz.1 +39 -0
  211. data/man/bundle-viz.1.txt +38 -0
  212. data/man/bundle-viz.ronn +5 -5
  213. data/man/bundle.1 +132 -0
  214. data/man/bundle.1.txt +113 -0
  215. data/man/bundle.ronn +5 -2
  216. data/man/gemfile.5 +679 -0
  217. data/man/gemfile.5.ronn +31 -0
  218. data/man/gemfile.5.txt +636 -0
  219. data/man/index.txt +23 -0
  220. metadata +21 -36
  221. data/.codeclimate.yml +0 -25
  222. data/.gitignore +0 -18
  223. data/.rspec +0 -3
  224. data/.rubocop.yml +0 -131
  225. data/.rubocop_todo.yml +0 -418
  226. data/.travis.yml +0 -122
  227. data/CODE_OF_CONDUCT.md +0 -42
  228. data/CONTRIBUTING.md +0 -17
  229. data/Rakefile +0 -338
  230. data/bin/rake +0 -19
  231. data/bin/rspec +0 -15
  232. data/bin/rubocop +0 -17
  233. data/bin/with_rubygems +0 -39
  234. data/bundler.gemspec +0 -48
  235. data/doc/README.md +0 -30
  236. data/doc/TROUBLESHOOTING.md +0 -64
  237. data/doc/contributing/BUG_TRIAGE.md +0 -36
  238. data/doc/contributing/COMMUNITY.md +0 -13
  239. data/doc/contributing/GETTING_HELP.md +0 -11
  240. data/doc/contributing/HOW_YOU_CAN_HELP.md +0 -27
  241. data/doc/contributing/ISSUES.md +0 -51
  242. data/doc/contributing/README.md +0 -38
  243. data/doc/development/NEW_FEATURES.md +0 -10
  244. data/doc/development/PULL_REQUESTS.md +0 -40
  245. data/doc/development/README.md +0 -19
  246. data/doc/development/RELEASING.md +0 -9
  247. data/doc/development/SETUP.md +0 -27
  248. data/doc/documentation/README.md +0 -29
  249. data/doc/documentation/VISION.md +0 -26
  250. data/doc/documentation/WRITING.md +0 -54
  251. data/task/release.rake +0 -116
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class Settings
5
+ class Validator
6
+ class Rule
7
+ attr_reader :description
8
+
9
+ def initialize(keys, description, &validate)
10
+ @keys = keys
11
+ @description = description
12
+ @validate = validate
13
+ end
14
+
15
+ def validate!(key, value, settings)
16
+ instance_exec(key, value, settings, &@validate)
17
+ end
18
+
19
+ def fail!(key, value, *reasons)
20
+ reasons.unshift @description
21
+ raise InvalidOption, "Setting `#{key}` to #{value.inspect} failed:\n#{reasons.map {|r| " - #{r}" }.join("\n")}"
22
+ end
23
+
24
+ def set(settings, key, value, *reasons)
25
+ hash_key = k(key)
26
+ return if settings[hash_key] == value
27
+ reasons.unshift @description
28
+ Bundler.ui.info "Setting `#{key}` to #{value.inspect}, since #{reasons.join(", ")}"
29
+ if value.nil?
30
+ settings.delete(hash_key)
31
+ else
32
+ settings[hash_key] = value
33
+ end
34
+ end
35
+
36
+ def k(key)
37
+ Bundler.settings.key_for(key)
38
+ end
39
+ end
40
+
41
+ def self.rules
42
+ @rules ||= Hash.new {|h, k| h[k] = [] }
43
+ end
44
+ private_class_method :rules
45
+
46
+ def self.rule(keys, description, &blk)
47
+ rule = Rule.new(keys, description, &blk)
48
+ keys.each {|k| rules[k] << rule }
49
+ end
50
+ private_class_method :rule
51
+
52
+ def self.validate!(key, value, settings)
53
+ rules_to_validate = rules[key]
54
+ rules_to_validate.each {|rule| rule.validate!(key, value, settings) }
55
+ end
56
+
57
+ rule %w[path path.system], "path and path.system are mutually exclusive" do |key, value, settings|
58
+ if key == "path" && value
59
+ set(settings, "path.system", nil)
60
+ elsif key == "path.system" && value
61
+ set(settings, :path, nil)
62
+ end
63
+ end
64
+
65
+ rule %w[with without], "a group cannot be in both `with` & `without` simultaneously" do |key, value, settings|
66
+ with = settings.fetch(k(:with), "").split(":").map(&:to_sym)
67
+ without = settings.fetch(k(:without), "").split(":").map(&:to_sym)
68
+
69
+ other_key = key == "with" ? :without : :with
70
+ other_setting = key == "with" ? without : with
71
+
72
+ conflicting = with & without
73
+ if conflicting.any?
74
+ fail!(key, value, "`#{other_key}` is current set to #{other_setting.inspect}", "the `#{conflicting.join("`, `")}` groups conflict")
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "bundler/shared_helpers"
3
4
 
4
5
  if Bundler::SharedHelpers.in_bundle?
@@ -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,23 +194,54 @@ 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
+ if dep.is_a?(Bundler::Dependency)
201
+ platform_string = dep.platforms.join(", ")
202
+ msg << " " << platform_string if !platform_string.empty? && platform_string != Gem::Platform::RUBY
203
+ end
204
+ msg << " from the `#{dep.source}` source" if print_source && dep.source
205
+ msg
206
+ end
207
+
208
+ def md5_available?
209
+ return @md5_available if defined?(@md5_available)
210
+ @md5_available = begin
211
+ require "openssl"
212
+ OpenSSL::Digest::MD5.digest("")
213
+ true
214
+ rescue LoadError
215
+ true
216
+ rescue OpenSSL::Digest::DigestError
217
+ false
218
+ end
219
+ end
220
+
173
221
  private
174
222
 
175
223
  def validate_bundle_path
176
- return unless Bundler.bundle_path.to_s.include?(File::PATH_SEPARATOR)
177
- message = "Your bundle path contains a '#{File::PATH_SEPARATOR}', " \
224
+ path_separator = Bundler.rubygems.path_separator
225
+ return unless Bundler.bundle_path.to_s.split(path_separator).size > 1
226
+ message = "Your bundle path contains text matching #{path_separator.inspect}, " \
178
227
  "which is the path separator for your system. Bundler cannot " \
179
228
  "function correctly when the Bundle path contains the " \
180
229
  "system's PATH separator. Please change your " \
181
- "bundle path to not include '#{File::PATH_SEPARATOR}'." \
230
+ "bundle path to not match #{path_separator.inspect}." \
182
231
  "\nYour current bundle path is '#{Bundler.bundle_path}'."
183
232
  raise Bundler::PathError, message
184
233
  end
185
234
 
186
- def find_gemfile
235
+ def find_gemfile(order_matters = false)
187
236
  given = ENV["BUNDLE_GEMFILE"]
188
237
  return given if given && !given.empty?
189
- find_file("Gemfile", "gems.rb")
238
+ names = gemfile_names
239
+ names.reverse! if order_matters && Bundler.feature_flag.prefer_gems_rb?
240
+ find_file(*names)
241
+ end
242
+
243
+ def gemfile_names
244
+ ["Gemfile", "gems.rb"]
190
245
  end
191
246
 
192
247
  def find_file(*names)
@@ -220,36 +275,47 @@ module Bundler
220
275
  end
221
276
  end
222
277
 
278
+ def set_env(key, value)
279
+ raise ArgumentError, "new key #{key}" unless EnvironmentPreserver::BUNDLER_KEYS.include?(key)
280
+ orig_key = "#{EnvironmentPreserver::BUNDLER_PREFIX}#{key}"
281
+ orig = ENV[key]
282
+ orig ||= EnvironmentPreserver::INTENTIONALLY_NIL
283
+ ENV[orig_key] ||= orig
284
+
285
+ ENV[key] = value
286
+ end
287
+ public :set_env
288
+
223
289
  def set_bundle_variables
224
290
  begin
225
- ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
291
+ Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
226
292
  rescue Gem::GemNotFoundException
227
- ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../exe/bundle", __FILE__)
293
+ Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", File.expand_path("../../../exe/bundle", __FILE__)
228
294
  end
229
295
 
230
296
  # Set BUNDLE_GEMFILE
231
- ENV["BUNDLE_GEMFILE"] = find_gemfile.to_s
232
- ENV["BUNDLER_VERSION"] = Bundler::VERSION
297
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile(:order_matters).to_s
298
+ Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
233
299
  end
234
300
 
235
301
  def set_path
236
302
  validate_bundle_path
237
303
  paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
238
304
  paths.unshift "#{Bundler.bundle_path}/bin"
239
- ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
305
+ Bundler::SharedHelpers.set_env "PATH", paths.uniq.join(File::PATH_SEPARATOR)
240
306
  end
241
307
 
242
308
  def set_rubyopt
243
309
  rubyopt = [ENV["RUBYOPT"]].compact
244
310
  return if !rubyopt.empty? && rubyopt.first =~ %r{-rbundler/setup}
245
311
  rubyopt.unshift %(-rbundler/setup)
246
- ENV["RUBYOPT"] = rubyopt.join(" ")
312
+ Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
247
313
  end
248
314
 
249
315
  def set_rubylib
250
316
  rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR)
251
317
  rubylib.unshift bundler_ruby_lib
252
- ENV["RUBYLIB"] = rubylib.uniq.join(File::PATH_SEPARATOR)
318
+ Bundler::SharedHelpers.set_env "RUBYLIB", rubylib.uniq.join(File::PATH_SEPARATOR)
253
319
  end
254
320
 
255
321
  def bundler_ruby_lib
@@ -280,12 +346,6 @@ module Bundler
280
346
  true
281
347
  end
282
348
 
283
- def deprecate_gemfile(gemfile)
284
- return unless gemfile && File.basename(gemfile) == "Gemfile"
285
- Bundler::SharedHelpers.major_deprecation \
286
- "gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock."
287
- end
288
-
289
349
  extend self
290
350
  end
291
351
  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,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class Source
4
5
  autoload :Gemspec, "bundler/source/gemspec"
5
6
  autoload :Git, "bundler/source/git"
7
+ autoload :Metadata, "bundler/source/metadata"
6
8
  autoload :Path, "bundler/source/path"
7
9
  autoload :Rubygems, "bundler/source/rubygems"
8
10
 
@@ -31,6 +33,11 @@ module Bundler
31
33
  spec.source == self
32
34
  end
33
35
 
36
+ # it's possible that gems from one source depend on gems from some
37
+ # other source, so now we download gemspecs and iterate over those
38
+ # dependencies, looking for gems we don't have info on yet.
39
+ def double_check_for(*); end
40
+
34
41
  def include?(other)
35
42
  other == self
36
43
  end
@@ -39,6 +46,10 @@ module Bundler
39
46
  "#<#{self.class}:0x#{object_id} #{self}>"
40
47
  end
41
48
 
49
+ def path?
50
+ instance_of?(Bundler::Source::Path)
51
+ end
52
+
42
53
  private
43
54
 
44
55
  def version_color(spec_version, locked_spec_version)
@@ -54,5 +65,26 @@ module Bundler
54
65
  def earlier_version?(spec_version, locked_spec_version)
55
66
  Gem::Version.new(spec_version) < Gem::Version.new(locked_spec_version)
56
67
  end
68
+
69
+ def print_using_message(message)
70
+ if !message.include?("(was ") && Bundler.feature_flag.suppress_install_using_messages?
71
+ Bundler.ui.debug message
72
+ else
73
+ Bundler.ui.info message
74
+ end
75
+ end
76
+
77
+ def extension_cache_path(spec)
78
+ return unless Bundler.feature_flag.global_gem_cache?
79
+ return unless source_slug = extension_cache_slug(spec)
80
+ Bundler.user_cache.join(
81
+ "extensions", Gem::Platform.local.to_s, Bundler.ruby_scope,
82
+ source_slug, spec.full_name
83
+ )
84
+ end
85
+
86
+ def extension_cache_slug(_)
87
+ nil
88
+ end
57
89
  end
58
90
  end
@@ -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,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require "fileutils"
2
+
3
+ require "bundler/vendored_fileutils"
3
4
  require "uri"
4
5
  require "digest/sha1"
5
6
 
@@ -18,7 +19,7 @@ module Bundler
18
19
  @allow_remote = false
19
20
 
20
21
  # 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] }
22
+ %w[ref branch tag revision].each {|k| options[k] = options[k].to_s if options[k] }
22
23
 
23
24
  @uri = options["uri"] || ""
24
25
  @branch = options["branch"]
@@ -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
@@ -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
 
@@ -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