bundler 2.0.2 → 2.1.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 (210) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +687 -574
  3. data/LICENSE.md +18 -19
  4. data/README.md +8 -7
  5. data/bundler.gemspec +5 -23
  6. data/exe/bundle +19 -3
  7. data/lib/bundler.rb +121 -68
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/capistrano.rb +5 -5
  10. data/lib/bundler/cli.rb +130 -124
  11. data/lib/bundler/cli/add.rb +27 -16
  12. data/lib/bundler/cli/common.rb +10 -11
  13. data/lib/bundler/cli/config.rb +161 -86
  14. data/lib/bundler/cli/console.rb +2 -2
  15. data/lib/bundler/cli/doctor.rb +4 -4
  16. data/lib/bundler/cli/exec.rb +4 -9
  17. data/lib/bundler/cli/gem.rb +5 -5
  18. data/lib/bundler/cli/info.rb +17 -5
  19. data/lib/bundler/cli/init.rb +1 -1
  20. data/lib/bundler/cli/install.rb +3 -3
  21. data/lib/bundler/cli/issue.rb +1 -1
  22. data/lib/bundler/cli/open.rb +10 -6
  23. data/lib/bundler/cli/outdated.rb +85 -81
  24. data/lib/bundler/cli/package.rb +8 -9
  25. data/lib/bundler/cli/plugin.rb +9 -2
  26. data/lib/bundler/cli/pristine.rb +1 -1
  27. data/lib/bundler/cli/show.rb +1 -1
  28. data/lib/bundler/cli/update.rb +32 -12
  29. data/lib/bundler/compact_index_client.rb +25 -9
  30. data/lib/bundler/compact_index_client/updater.rb +2 -6
  31. data/lib/bundler/current_ruby.rb +8 -7
  32. data/lib/bundler/definition.rb +33 -26
  33. data/lib/bundler/dependency.rb +16 -4
  34. data/lib/bundler/deployment.rb +2 -2
  35. data/lib/bundler/dsl.rb +18 -42
  36. data/lib/bundler/env.rb +6 -5
  37. data/lib/bundler/environment_preserver.rb +0 -1
  38. data/lib/bundler/feature_flag.rb +0 -12
  39. data/lib/bundler/fetcher.rb +14 -11
  40. data/lib/bundler/fetcher/compact_index.rb +26 -12
  41. data/lib/bundler/fetcher/dependency.rb +1 -1
  42. data/lib/bundler/fetcher/downloader.rb +3 -0
  43. data/lib/bundler/fetcher/index.rb +4 -2
  44. data/lib/bundler/friendly_errors.rb +4 -5
  45. data/lib/bundler/gem_helper.rb +8 -8
  46. data/lib/bundler/gem_helpers.rb +2 -4
  47. data/lib/bundler/gem_tasks.rb +1 -1
  48. data/lib/bundler/gem_version_promoter.rb +3 -3
  49. data/lib/bundler/graph.rb +2 -2
  50. data/lib/bundler/injector.rb +3 -1
  51. data/lib/bundler/inline.rb +19 -18
  52. data/lib/bundler/installer.rb +7 -14
  53. data/lib/bundler/installer/gem_installer.rb +5 -1
  54. data/lib/bundler/installer/parallel_installer.rb +4 -4
  55. data/lib/bundler/installer/standalone.rb +1 -2
  56. data/lib/bundler/lazy_specification.rb +2 -2
  57. data/lib/bundler/lockfile_parser.rb +13 -21
  58. data/lib/bundler/match_platform.rb +1 -1
  59. data/lib/bundler/plugin.rb +29 -18
  60. data/lib/bundler/plugin/api.rb +1 -1
  61. data/lib/bundler/plugin/api/source.rb +2 -2
  62. data/lib/bundler/plugin/index.rb +10 -2
  63. data/lib/bundler/plugin/installer.rb +28 -15
  64. data/lib/bundler/psyched_yaml.rb +1 -1
  65. data/lib/bundler/resolver.rb +72 -24
  66. data/lib/bundler/resolver/spec_group.rb +2 -2
  67. data/lib/bundler/retry.rb +2 -2
  68. data/lib/bundler/ruby_version.rb +4 -19
  69. data/lib/bundler/rubygems_ext.rb +10 -65
  70. data/lib/bundler/rubygems_gem_installer.rb +1 -1
  71. data/lib/bundler/rubygems_integration.rb +135 -403
  72. data/lib/bundler/runtime.rb +2 -9
  73. data/lib/bundler/settings.rb +15 -48
  74. data/lib/bundler/setup.rb +6 -5
  75. data/lib/bundler/shared_helpers.rb +53 -68
  76. data/lib/bundler/similarity_detector.rb +2 -2
  77. data/lib/bundler/source.rb +5 -5
  78. data/lib/bundler/source/git.rb +19 -12
  79. data/lib/bundler/source/git/git_proxy.rb +35 -39
  80. data/lib/bundler/source/metadata.rb +7 -2
  81. data/lib/bundler/source/path.rb +13 -8
  82. data/lib/bundler/source/rubygems.rb +11 -5
  83. data/lib/bundler/source/rubygems/remote.rb +1 -2
  84. data/lib/bundler/source_list.rb +9 -12
  85. data/lib/bundler/spec_set.rb +1 -6
  86. data/lib/bundler/stub_specification.rb +18 -30
  87. data/lib/bundler/templates/Executable.bundler +22 -13
  88. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +3 -3
  89. data/lib/bundler/templates/newgem/Gemfile.tt +8 -0
  90. data/lib/bundler/templates/newgem/README.md.tt +4 -3
  91. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -18
  92. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  93. data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
  94. data/lib/bundler/ui.rb +3 -3
  95. data/lib/bundler/ui/rg_proxy.rb +1 -1
  96. data/lib/bundler/ui/shell.rb +4 -8
  97. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
  98. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
  99. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
  100. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  101. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1 -1
  102. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +6 -6
  103. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  104. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  105. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  111. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +30 -8
  112. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +4 -4
  114. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
  115. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +248 -279
  116. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  117. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  118. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  119. data/lib/bundler/vendor/thor/lib/thor.rb +1 -1
  120. data/lib/bundler/vendor/thor/lib/thor/actions.rb +7 -7
  121. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  122. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
  123. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  124. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -1
  125. data/lib/bundler/vendor/thor/lib/thor/base.rb +13 -13
  126. data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
  127. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  128. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  129. data/lib/bundler/vendor/thor/lib/thor/runner.rb +4 -4
  130. data/lib/bundler/vendor/thor/lib/thor/shell.rb +3 -3
  131. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -1
  132. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  133. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  134. data/lib/bundler/vendored_fileutils.rb +1 -6
  135. data/lib/bundler/vendored_molinillo.rb +1 -1
  136. data/lib/bundler/vendored_persistent.rb +7 -5
  137. data/lib/bundler/vendored_thor.rb +2 -2
  138. data/lib/bundler/version.rb +1 -20
  139. data/lib/bundler/version_ranges.rb +51 -5
  140. data/lib/bundler/vlad.rb +3 -3
  141. data/lib/bundler/worker.rb +1 -3
  142. data/lib/bundler/yaml_serializer.rb +2 -3
  143. data/man/bundle-add.1 +10 -2
  144. data/man/bundle-add.1.txt +11 -5
  145. data/man/bundle-add.ronn +7 -1
  146. data/man/bundle-binstubs.1 +2 -2
  147. data/man/bundle-binstubs.1.txt +2 -2
  148. data/man/bundle-binstubs.ronn +1 -1
  149. data/man/bundle-check.1 +1 -1
  150. data/man/bundle-check.1.txt +6 -6
  151. data/man/bundle-clean.1 +1 -1
  152. data/man/bundle-clean.1.txt +1 -1
  153. data/man/bundle-config.1 +35 -35
  154. data/man/bundle-config.1.txt +65 -66
  155. data/man/bundle-config.ronn +41 -39
  156. data/man/bundle-doctor.1 +1 -1
  157. data/man/bundle-doctor.1.txt +1 -1
  158. data/man/bundle-exec.1 +1 -1
  159. data/man/bundle-exec.1.txt +1 -1
  160. data/man/bundle-gem.1 +1 -1
  161. data/man/bundle-gem.1.txt +3 -3
  162. data/man/bundle-info.1 +1 -1
  163. data/man/bundle-info.1.txt +1 -1
  164. data/man/bundle-init.1 +1 -1
  165. data/man/bundle-init.1.txt +1 -1
  166. data/man/bundle-inject.1 +1 -1
  167. data/man/bundle-inject.1.txt +1 -1
  168. data/man/bundle-install.1 +8 -5
  169. data/man/bundle-install.1.txt +56 -51
  170. data/man/bundle-install.ronn +9 -4
  171. data/man/bundle-list.1 +1 -1
  172. data/man/bundle-list.1.txt +1 -1
  173. data/man/bundle-lock.1 +1 -1
  174. data/man/bundle-lock.1.txt +16 -16
  175. data/man/bundle-open.1 +1 -1
  176. data/man/bundle-open.1.txt +1 -1
  177. data/man/bundle-outdated.1 +1 -1
  178. data/man/bundle-outdated.1.txt +1 -1
  179. data/man/bundle-package.1 +1 -1
  180. data/man/bundle-package.1.txt +1 -1
  181. data/man/bundle-platform.1 +1 -1
  182. data/man/bundle-platform.1.txt +1 -1
  183. data/man/bundle-pristine.1 +1 -1
  184. data/man/bundle-pristine.1.txt +1 -1
  185. data/man/bundle-remove.1 +1 -1
  186. data/man/bundle-remove.1.txt +1 -1
  187. data/man/bundle-show.1 +1 -1
  188. data/man/bundle-show.1.txt +1 -1
  189. data/man/bundle-update.1 +4 -4
  190. data/man/bundle-update.1.txt +64 -65
  191. data/man/bundle-update.ronn +3 -3
  192. data/man/bundle-viz.1 +1 -1
  193. data/man/bundle-viz.1.txt +1 -1
  194. data/man/bundle.1 +2 -2
  195. data/man/bundle.1.txt +7 -7
  196. data/man/bundle.ronn +1 -1
  197. data/man/gemfile.5 +12 -15
  198. data/man/gemfile.5.ronn +9 -13
  199. data/man/gemfile.5.txt +103 -107
  200. metadata +11 -112
  201. data/exe/bundle_ruby +0 -60
  202. data/lib/bundler/cli/cache.rb +0 -36
  203. data/lib/bundler/compatibility_guard.rb +0 -13
  204. data/lib/bundler/ssl_certs/.document +0 -1
  205. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  206. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  207. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  208. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  209. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  210. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
@@ -34,14 +34,7 @@ module Bundler
34
34
  spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
35
35
  end.reverse.flatten
36
36
 
37
- # See Gem::Specification#add_self_to_load_path (since RubyGems 1.8)
38
- if insert_index = Bundler.rubygems.load_path_insert_index
39
- # Gem directories must come after -I and ENV['RUBYLIB']
40
- $LOAD_PATH.insert(insert_index, *load_paths)
41
- else
42
- # We are probably testing in core, -I and RUBYLIB don't apply
43
- $LOAD_PATH.unshift(*load_paths)
44
- end
37
+ Bundler.rubygems.add_to_load_path(load_paths)
45
38
 
46
39
  setup_manpath
47
40
 
@@ -163,7 +156,7 @@ module Bundler
163
156
  gem_dirs = Dir["#{Gem.dir}/gems/*"]
164
157
  gem_files = Dir["#{Gem.dir}/cache/*.gem"]
165
158
  gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
166
- extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"]
159
+ extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"] + Dir["#{Gem.dir}/bundler/gems/extensions/*/*/*"]
167
160
  spec_gem_paths = []
168
161
  # need to keep git sources around
169
162
  spec_git_paths = @definition.spec_git_paths
@@ -4,9 +4,9 @@ require "uri"
4
4
 
5
5
  module Bundler
6
6
  class Settings
7
- autoload :Mirror, "bundler/mirror"
8
- autoload :Mirrors, "bundler/mirror"
9
- autoload :Validator, "bundler/settings/validator"
7
+ autoload :Mirror, File.expand_path("mirror", __dir__)
8
+ autoload :Mirrors, File.expand_path("mirror", __dir__)
9
+ autoload :Validator, File.expand_path("settings/validator", __dir__)
10
10
 
11
11
  BOOL_KEYS = %w[
12
12
  allow_bundler_dependency_conflicts
@@ -17,8 +17,6 @@ module Bundler
17
17
  auto_config_jobs
18
18
  cache_all
19
19
  cache_all_platforms
20
- cache_command_is_package
21
- console_command
22
20
  default_install_uses_path
23
21
  deployment
24
22
  deployment_means_frozen
@@ -29,29 +27,24 @@ module Bundler
29
27
  disable_platform_warnings
30
28
  disable_shared_gems
31
29
  disable_version_check
32
- error_on_stderr
33
30
  force_ruby_platform
34
31
  forget_cli_options
35
32
  frozen
36
33
  gem.coc
37
34
  gem.mit
38
- global_path_appends_ruby_scope
39
35
  global_gem_cache
40
36
  ignore_messages
41
37
  init_gems_rb
42
- list_command
43
- lockfile_upgrade_warning
44
- lockfile_uses_separate_rubygems_sources
45
- major_deprecations
46
38
  no_install
47
39
  no_prune
48
40
  only_update_to_newer_versions
49
41
  path_relative_to_cwd
50
42
  path.system
51
43
  plugins
52
- prefer_gems_rb
44
+ prefer_patch
53
45
  print_only_version_number
54
46
  setup_makes_kernel_gem_public
47
+ silence_deprecations
55
48
  silence_root_warning
56
49
  skip_default_git_sources
57
50
  specific_platform
@@ -59,7 +52,6 @@ module Bundler
59
52
  unlock_source_unlocks_spec
60
53
  update_requires_all_flag
61
54
  use_gem_version_promoter_for_major_updates
62
- viz_command
63
55
  ].freeze
64
56
 
65
57
  NUMBER_KEYS = %w[
@@ -76,7 +68,9 @@ module Bundler
76
68
  ].freeze
77
69
 
78
70
  DEFAULT_CONFIG = {
71
+ :silence_deprecations => false,
79
72
  :disable_version_check => true,
73
+ :prefer_patch => false,
80
74
  :redirect => 5,
81
75
  :retry => 3,
82
76
  :timeout => 10,
@@ -107,18 +101,6 @@ module Bundler
107
101
  temporary(key => value)
108
102
  value
109
103
  else
110
- command = if value.nil?
111
- "bundle config --delete #{key}"
112
- else
113
- "bundle config #{key} #{Array(value).join(":")}"
114
- end
115
-
116
- Bundler::SharedHelpers.major_deprecation 3,\
117
- "flags passed to commands " \
118
- "will no longer be automatically remembered. Instead please set flags " \
119
- "you want remembered between commands using `bundle config " \
120
- "<setting name> <setting value>`, i.e. `#{command}`"
121
-
122
104
  set_local(key, value)
123
105
  end
124
106
  end
@@ -221,23 +203,22 @@ module Bundler
221
203
  locations
222
204
  end
223
205
 
224
- # for legacy reasons, in Bundler 1, the ruby scope isnt appended when the setting comes from ENV or the global config,
225
- # nor do we respect :disable_shared_gems
206
+ # for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems
226
207
  def path
227
208
  key = key_for(:path)
228
209
  path = ENV[key] || @global_config[key]
229
210
  if path && !@temporary.key?(key) && !@local_config.key?(key)
230
- return Path.new(path, Bundler.feature_flag.global_path_appends_ruby_scope?, false, false)
211
+ return Path.new(path, false, false)
231
212
  end
232
213
 
233
214
  system_path = self["path.system"] || (self[:disable_shared_gems] == false)
234
- Path.new(self[:path], true, system_path, Bundler.feature_flag.default_install_uses_path?)
215
+ Path.new(self[:path], system_path, Bundler.feature_flag.default_install_uses_path?)
235
216
  end
236
217
 
237
- Path = Struct.new(:explicit_path, :append_ruby_scope, :system_path, :default_install_uses_path) do
218
+ Path = Struct.new(:explicit_path, :system_path, :default_install_uses_path) do
238
219
  def path
239
220
  path = base_path
240
- path = File.join(path, Bundler.ruby_scope) if append_ruby_scope && !use_system_gems?
221
+ path = File.join(path, Bundler.ruby_scope) unless use_system_gems?
241
222
  path
242
223
  end
243
224
 
@@ -372,7 +353,7 @@ module Bundler
372
353
  return unless file
373
354
  SharedHelpers.filesystem_access(file) do |p|
374
355
  FileUtils.mkdir_p(p.dirname)
375
- require "bundler/yaml_serializer"
356
+ require_relative "yaml_serializer"
376
357
  p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
377
358
  end
378
359
  end
@@ -407,26 +388,12 @@ module Bundler
407
388
  Pathname.new(@root).join("config") if @root
408
389
  end
409
390
 
410
- CONFIG_REGEX = %r{ # rubocop:disable Style/RegexpLiteral
411
- ^
412
- (BUNDLE_.+):\s # the key
413
- (?: !\s)? # optional exclamation mark found with ruby 1.9.3
414
- (['"]?) # optional opening quote
415
- (.* # contents of the value
416
- (?: # optionally, up until the next key
417
- (\n(?!BUNDLE).+)*
418
- )
419
- )
420
- \2 # matching closing quote
421
- $
422
- }xo
423
-
424
391
  def load_config(config_file)
425
392
  return {} if !config_file || ignore_config?
426
393
  SharedHelpers.filesystem_access(config_file, :read) do |file|
427
394
  valid_file = file.exist? && !file.size.zero?
428
395
  return {} unless valid_file
429
- require "bundler/yaml_serializer"
396
+ require_relative "yaml_serializer"
430
397
  YAMLSerializer.load file.read
431
398
  end
432
399
  end
@@ -442,7 +409,7 @@ module Bundler
442
409
  (https?.*?) # URI
443
410
  (\.#{Regexp.union(PER_URI_OPTIONS)})? # optional suffix key
444
411
  \z
445
- /ix
412
+ /ix.freeze
446
413
 
447
414
  # TODO: duplicates Rubygems#normalize_uri
448
415
  # TODO: is this the correct place to validate mirror URIs?
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/shared_helpers"
3
+ require_relative "shared_helpers"
4
4
 
5
5
  if Bundler::SharedHelpers.in_bundle?
6
- require "bundler"
6
+ require_relative "../bundler"
7
7
 
8
8
  if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"]
9
+ Bundler.ui = Bundler::UI::Shell.new
9
10
  begin
10
11
  Bundler.setup
11
12
  rescue Bundler::BundlerError => e
12
- puts "\e[31m#{e.message}\e[0m"
13
- puts e.backtrace.join("\n") if ENV["DEBUG"]
13
+ Bundler.ui.warn "\e[31m#{e.message}\e[0m"
14
+ Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"]
14
15
  if e.is_a?(Bundler::GemNotFound)
15
- puts "\e[33mRun `bundle install` to install missing gems.\e[0m"
16
+ Bundler.ui.warn "\e[33mRun `bundle install` to install missing gems.\e[0m"
16
17
  end
17
18
  exit e.status_code
18
19
  end
@@ -1,26 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/compatibility_guard"
4
-
5
3
  require "pathname"
6
4
  require "rbconfig"
7
- require "rubygems"
8
-
9
- require "bundler/version"
10
- require "bundler/constants"
11
- require "bundler/rubygems_integration"
12
- require "bundler/current_ruby"
13
-
14
- module Gem
15
- class Dependency
16
- # This is only needed for RubyGems < 1.4
17
- unless method_defined? :requirement
18
- def requirement
19
- version_requirements
20
- end
21
- end
22
- end
23
- end
5
+
6
+ require_relative "version"
7
+ require_relative "constants"
8
+ require_relative "rubygems_integration"
9
+ require_relative "current_ruby"
24
10
 
25
11
  module Bundler
26
12
  module SharedHelpers
@@ -31,7 +17,7 @@ module Bundler
31
17
  end
32
18
 
33
19
  def default_gemfile
34
- gemfile = find_gemfile(:order_matters)
20
+ gemfile = find_gemfile
35
21
  raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
36
22
  Pathname.new(gemfile).untaint.expand_path
37
23
  end
@@ -114,9 +100,7 @@ module Bundler
114
100
  #
115
101
  # @see {Bundler::PermissionError}
116
102
  def filesystem_access(path, action = :write, &block)
117
- # Use block.call instead of yield because of a bug in Ruby 2.2.2
118
- # See https://github.com/bundler/bundler/issues/5341 for details
119
- block.call(path.dup.untaint)
103
+ yield(path.dup.untaint)
120
104
  rescue Errno::EACCES
121
105
  raise PermissionError.new(path, action)
122
106
  rescue Errno::EAGAIN
@@ -143,32 +127,27 @@ module Bundler
143
127
  def major_deprecation(major_version, message)
144
128
  bundler_major_version = Bundler.bundler_major_version
145
129
  if bundler_major_version > major_version
146
- require "bundler/errors"
147
- raise DeprecatedError, "[REMOVED FROM #{major_version.succ}.0] #{message}"
130
+ require_relative "errors"
131
+ raise DeprecatedError, "[REMOVED] #{message}"
148
132
  end
149
133
 
150
- return unless bundler_major_version >= major_version || prints_major_deprecations?
134
+ return unless bundler_major_version >= major_version && prints_major_deprecations?
151
135
  @major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true)
152
- ui = Bundler.ui.is_a?(@major_deprecation_ui.class) ? Bundler.ui : @major_deprecation_ui
153
- ui.warn("[DEPRECATED FOR #{major_version}.0] #{message}")
136
+ with_major_deprecation_ui do |ui|
137
+ ui.warn("[DEPRECATED] #{message}")
138
+ end
154
139
  end
155
140
 
156
141
  def print_major_deprecations!
157
142
  multiple_gemfiles = search_up(".") do |dir|
158
143
  gemfiles = gemfile_names.select {|gf| File.file? File.expand_path(gf, dir) }
159
144
  next if gemfiles.empty?
160
- break false if gemfiles.size == 1
161
- end
162
- if multiple_gemfiles && Bundler.bundler_major_version == 2
163
- Bundler::SharedHelpers.major_deprecation 3, \
164
- "gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock."
165
- end
166
-
167
- if RUBY_VERSION < "2"
168
- major_deprecation(2, "Bundler will only support ruby >= 2.0, you are running #{RUBY_VERSION}")
145
+ break gemfiles.size != 1
169
146
  end
170
- return if Bundler.rubygems.provides?(">= 2")
171
- major_deprecation(2, "Bundler will only support rubygems >= 2.0, you are running #{Bundler.rubygems.version}")
147
+ return unless multiple_gemfiles
148
+ message = "Multiple gemfiles (gems.rb and Gemfile) detected. " \
149
+ "Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
150
+ Bundler.ui.warn message
172
151
  end
173
152
 
174
153
  def trap(signal, override = false, &block)
@@ -233,6 +212,21 @@ module Bundler
233
212
 
234
213
  private
235
214
 
215
+ def with_major_deprecation_ui(&block)
216
+ ui = Bundler.ui
217
+
218
+ if ui.is_a?(@major_deprecation_ui.class)
219
+ yield ui
220
+ else
221
+ begin
222
+ Bundler.ui = @major_deprecation_ui
223
+ yield Bundler.ui
224
+ ensure
225
+ Bundler.ui = ui
226
+ end
227
+ end
228
+ end
229
+
236
230
  def validate_bundle_path
237
231
  path_separator = Bundler.rubygems.path_separator
238
232
  return unless Bundler.bundle_path.to_s.split(path_separator).size > 1
@@ -245,16 +239,14 @@ module Bundler
245
239
  raise Bundler::PathError, message
246
240
  end
247
241
 
248
- def find_gemfile(order_matters = false)
242
+ def find_gemfile
249
243
  given = ENV["BUNDLE_GEMFILE"]
250
244
  return given if given && !given.empty?
251
- names = gemfile_names
252
- names.reverse! if order_matters && Bundler.feature_flag.prefer_gems_rb?
253
- find_file(*names)
245
+ find_file(*gemfile_names)
254
246
  end
255
247
 
256
248
  def gemfile_names
257
- ["Gemfile", "gems.rb"]
249
+ ["gems.rb", "Gemfile"]
258
250
  end
259
251
 
260
252
  def find_file(*names)
@@ -276,7 +268,7 @@ module Bundler
276
268
  until !File.directory?(current) || current == previous
277
269
  if ENV["BUNDLE_SPEC_RUN"]
278
270
  # avoid stepping above the tmp directory when testing
279
- gemspec = if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]
271
+ gemspec = if ENV["GEM_COMMAND"]
280
272
  # for Ruby Core
281
273
  "lib/bundler/bundler.gemspec"
282
274
  else
@@ -308,21 +300,17 @@ module Bundler
308
300
  public :set_env
309
301
 
310
302
  def set_bundle_variables
311
- begin
312
- exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
313
- unless File.exist?(exe_file)
314
- exe_file = File.expand_path("../../../exe/bundle", __FILE__)
315
- end
316
- Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
317
- rescue Gem::GemNotFoundException
318
- exe_file = File.expand_path("../../../exe/bundle", __FILE__)
319
- # for Ruby core repository
320
- exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file)
321
- Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
322
- end
303
+ # bundler exe & lib folders have same root folder, typical gem installation
304
+ exe_file = File.expand_path("../../../exe/bundle", __FILE__)
305
+
306
+ # for Ruby core repository testing
307
+ exe_file = File.expand_path("../../../libexec/bundle", __FILE__) unless File.exist?(exe_file)
323
308
 
324
- # Set BUNDLE_GEMFILE
325
- Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile(:order_matters).to_s
309
+ # bundler is a default gem, exe path is separate
310
+ exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
311
+
312
+ Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
313
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s
326
314
  Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
327
315
  end
328
316
 
@@ -335,8 +323,9 @@ module Bundler
335
323
 
336
324
  def set_rubyopt
337
325
  rubyopt = [ENV["RUBYOPT"]].compact
338
- return if !rubyopt.empty? && rubyopt.first =~ %r{-rbundler/setup}
339
- rubyopt.unshift %(-rbundler/setup)
326
+ setup_require = "-r#{File.expand_path("setup", __dir__)}"
327
+ return if !rubyopt.empty? && rubyopt.first =~ /#{setup_require}/
328
+ rubyopt.unshift setup_require
340
329
  Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
341
330
  end
342
331
 
@@ -351,9 +340,6 @@ module Bundler
351
340
  end
352
341
 
353
342
  def clean_load_path
354
- # handle 1.9 where system gems are always on the load path
355
- return unless defined?(::Gem)
356
-
357
343
  bundler_lib = bundler_ruby_lib
358
344
 
359
345
  loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
@@ -373,10 +359,9 @@ module Bundler
373
359
  end
374
360
 
375
361
  def prints_major_deprecations?
376
- require "bundler"
377
- deprecation_release = Bundler::VERSION.split(".").drop(1).include?("99")
378
- return false if !deprecation_release && !Bundler.settings[:major_deprecations]
379
- require "bundler/deprecate"
362
+ require_relative "../bundler"
363
+ return false if Bundler.settings[:silence_deprecations]
364
+ require_relative "deprecate"
380
365
  return false if Bundler::Deprecate.skip
381
366
  true
382
367
  end
@@ -28,7 +28,7 @@ module Bundler
28
28
 
29
29
  protected
30
30
 
31
- # http://www.informit.com/articles/article.aspx?p=683059&seqNum=36
31
+ # https://www.informit.com/articles/article.aspx?p=683059&seqNum=36
32
32
  def levenshtein_distance(this, that, ins = 2, del = 2, sub = 1)
33
33
  # ins, del, sub are weighted costs
34
34
  return nil if this.nil?
@@ -51,7 +51,7 @@ module Bundler
51
51
  dm[i][j] = [
52
52
  dm[i - 1][j - 1] + (this[j - 1] == that[i - 1] ? 0 : sub),
53
53
  dm[i][j - 1] + ins,
54
- dm[i - 1][j] + del
54
+ dm[i - 1][j] + del,
55
55
  ].min
56
56
  end
57
57
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Bundler
4
4
  class Source
5
- autoload :Gemspec, "bundler/source/gemspec"
6
- autoload :Git, "bundler/source/git"
7
- autoload :Metadata, "bundler/source/metadata"
8
- autoload :Path, "bundler/source/path"
9
- autoload :Rubygems, "bundler/source/rubygems"
5
+ autoload :Gemspec, File.expand_path("source/gemspec", __dir__)
6
+ autoload :Git, File.expand_path("source/git", __dir__)
7
+ autoload :Metadata, File.expand_path("source/metadata", __dir__)
8
+ autoload :Path, File.expand_path("source/path", __dir__)
9
+ autoload :Rubygems, File.expand_path("source/rubygems", __dir__)
10
10
 
11
11
  attr_accessor :dependency_names
12
12