bundler 2.2.26 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +206 -1
  3. data/README.md +1 -1
  4. data/exe/bundle +7 -8
  5. data/lib/bundler/.document +1 -0
  6. data/lib/bundler/build_metadata.rb +2 -2
  7. data/lib/bundler/cli/check.rb +1 -1
  8. data/lib/bundler/cli/config.rb +10 -1
  9. data/lib/bundler/cli/doctor.rb +12 -3
  10. data/lib/bundler/cli/gem.rb +98 -9
  11. data/lib/bundler/cli/info.rb +26 -5
  12. data/lib/bundler/cli/install.rb +8 -28
  13. data/lib/bundler/cli/issue.rb +4 -3
  14. data/lib/bundler/cli/platform.rb +1 -1
  15. data/lib/bundler/cli/remove.rb +1 -2
  16. data/lib/bundler/cli/update.rb +8 -4
  17. data/lib/bundler/cli.rb +13 -11
  18. data/lib/bundler/compact_index_client/cache.rb +0 -9
  19. data/lib/bundler/compact_index_client/updater.rb +0 -5
  20. data/lib/bundler/compact_index_client.rb +2 -8
  21. data/lib/bundler/definition.rb +79 -133
  22. data/lib/bundler/dependency.rb +5 -7
  23. data/lib/bundler/digest.rb +71 -0
  24. data/lib/bundler/dsl.rb +18 -30
  25. data/lib/bundler/endpoint_specification.rb +21 -11
  26. data/lib/bundler/env.rb +1 -1
  27. data/lib/bundler/environment_preserver.rb +4 -1
  28. data/lib/bundler/errors.rb +18 -2
  29. data/lib/bundler/fetcher/compact_index.rb +9 -14
  30. data/lib/bundler/fetcher/index.rb +0 -26
  31. data/lib/bundler/fetcher.rb +13 -20
  32. data/lib/bundler/friendly_errors.rb +5 -30
  33. data/lib/bundler/gem_helper.rb +7 -18
  34. data/lib/bundler/injector.rb +10 -1
  35. data/lib/bundler/installer/gem_installer.rb +1 -6
  36. data/lib/bundler/installer.rb +1 -5
  37. data/lib/bundler/lazy_specification.rb +19 -3
  38. data/lib/bundler/lockfile_generator.rb +1 -1
  39. data/lib/bundler/lockfile_parser.rb +10 -12
  40. data/lib/bundler/man/bundle-add.1 +10 -2
  41. data/lib/bundler/man/bundle-add.1.ronn +7 -1
  42. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  43. data/lib/bundler/man/bundle-cache.1 +1 -1
  44. data/lib/bundler/man/bundle-check.1 +1 -1
  45. data/lib/bundler/man/bundle-clean.1 +1 -1
  46. data/lib/bundler/man/bundle-config.1 +5 -5
  47. data/lib/bundler/man/bundle-config.1.ronn +5 -5
  48. data/lib/bundler/man/bundle-doctor.1 +1 -1
  49. data/lib/bundler/man/bundle-exec.1 +1 -1
  50. data/lib/bundler/man/bundle-gem.1 +14 -1
  51. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  52. data/lib/bundler/man/bundle-info.1 +1 -1
  53. data/lib/bundler/man/bundle-init.1 +1 -1
  54. data/lib/bundler/man/bundle-inject.1 +1 -1
  55. data/lib/bundler/man/bundle-install.1 +2 -2
  56. data/lib/bundler/man/bundle-install.1.ronn +2 -2
  57. data/lib/bundler/man/bundle-list.1 +1 -1
  58. data/lib/bundler/man/bundle-lock.1 +1 -1
  59. data/lib/bundler/man/bundle-open.1 +1 -1
  60. data/lib/bundler/man/bundle-outdated.1 +1 -1
  61. data/lib/bundler/man/bundle-platform.1 +1 -1
  62. data/lib/bundler/man/bundle-pristine.1 +1 -1
  63. data/lib/bundler/man/bundle-remove.1 +1 -1
  64. data/lib/bundler/man/bundle-show.1 +1 -1
  65. data/lib/bundler/man/bundle-update.1 +2 -2
  66. data/lib/bundler/man/bundle-update.1.ronn +2 -1
  67. data/lib/bundler/man/bundle-viz.1 +1 -1
  68. data/lib/bundler/man/bundle.1 +1 -1
  69. data/lib/bundler/man/gemfile.5 +28 -2
  70. data/lib/bundler/man/gemfile.5.ronn +9 -1
  71. data/lib/bundler/plugin/api/source.rb +1 -0
  72. data/lib/bundler/plugin/installer.rb +3 -1
  73. data/lib/bundler/plugin.rb +23 -6
  74. data/lib/bundler/process_lock.rb +1 -1
  75. data/lib/bundler/remote_specification.rb +7 -0
  76. data/lib/bundler/resolver/spec_group.rb +1 -1
  77. data/lib/bundler/resolver.rb +38 -40
  78. data/lib/bundler/ruby_version.rb +1 -1
  79. data/lib/bundler/rubygems_ext.rb +19 -10
  80. data/lib/bundler/rubygems_gem_installer.rb +21 -5
  81. data/lib/bundler/rubygems_integration.rb +40 -70
  82. data/lib/bundler/runtime.rb +2 -2
  83. data/lib/bundler/self_manager.rb +168 -0
  84. data/lib/bundler/settings.rb +11 -2
  85. data/lib/bundler/shared_helpers.rb +4 -12
  86. data/lib/bundler/source/git/git_proxy.rb +7 -4
  87. data/lib/bundler/source/git.rb +22 -4
  88. data/lib/bundler/source/metadata.rb +1 -1
  89. data/lib/bundler/source/rubygems.rb +60 -85
  90. data/lib/bundler/source/rubygems_aggregate.rb +1 -1
  91. data/lib/bundler/source.rb +3 -1
  92. data/lib/bundler/source_list.rb +11 -29
  93. data/lib/bundler/spec_set.rb +2 -2
  94. data/lib/bundler/templates/Executable.bundler +1 -1
  95. data/lib/bundler/templates/Gemfile +0 -2
  96. data/lib/bundler/templates/gems.rb +0 -3
  97. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  98. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  99. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +4 -3
  100. data/lib/bundler/templates/newgem/newgem.gemspec.tt +15 -15
  101. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  102. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  103. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  104. data/lib/bundler/ui/shell.rb +1 -1
  105. data/lib/bundler/vendor/.document +1 -0
  106. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  107. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  108. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  109. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  110. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  111. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  112. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  114. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  115. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  116. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +6 -6
  117. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  118. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  119. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  120. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  121. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  122. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  123. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  124. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  125. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  126. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  127. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  128. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  129. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  130. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  131. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  132. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  133. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  134. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  135. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  136. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  137. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  138. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  139. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  140. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  141. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  142. data/lib/bundler/vendored_tsort.rb +4 -0
  143. data/lib/bundler/version.rb +1 -1
  144. data/lib/bundler/worker.rb +2 -2
  145. data/lib/bundler.rb +23 -22
  146. metadata +25 -10
  147. data/lib/bundler/gemdeps.rb +0 -29
  148. data/lib/bundler/psyched_yaml.rb +0 -22
  149. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -20,9 +20,10 @@ module Bundler
20
20
 
21
21
  Hopefully the troubleshooting steps above resolved your problem! If things
22
22
  still aren't working the way you expect them to, please let us know so
23
- that we can diagnose and help fix the problem you're having. Please
24
- view the Filing Issues guide for more information:
25
- https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/ISSUES.md
23
+ that we can diagnose and help fix the problem you're having, by filling
24
+ in the new issue form located at
25
+ https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md,
26
+ and copy and pasting the information below.
26
27
 
27
28
  EOS
28
29
 
@@ -23,7 +23,7 @@ module Bundler
23
23
  output << "No ruby version specified"
24
24
  end
25
25
  else
26
- output << "Your platform is: #{RUBY_PLATFORM}"
26
+ output << "Your platform is: #{Gem::Platform.local}"
27
27
  output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
28
28
 
29
29
  if ruby_version
@@ -11,8 +11,7 @@ module Bundler
11
11
  raise InvalidOption, "Please specify gems to remove." if @gems.empty?
12
12
 
13
13
  Injector.remove(@gems, {})
14
-
15
- Installer.install(Bundler.root, Bundler.definition) if @options["install"]
14
+ Installer.install(Bundler.root, Bundler.definition)
16
15
  end
17
16
  end
18
17
  end
@@ -11,12 +11,16 @@ module Bundler
11
11
  def run
12
12
  Bundler.ui.level = "warn" if options[:quiet]
13
13
 
14
+ update_bundler = options[:bundler]
15
+
16
+ Bundler.self_manager.update_bundler_and_restart_with_it_if_needed(update_bundler) if update_bundler
17
+
14
18
  Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
15
19
 
16
20
  sources = Array(options[:source])
17
21
  groups = Array(options[:group]).map(&:to_sym)
18
22
 
19
- full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
23
+ full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !update_bundler
20
24
 
21
25
  if full_update && !options[:all]
22
26
  if Bundler.feature_flag.update_requires_all_flag?
@@ -49,7 +53,7 @@ module Bundler
49
53
 
50
54
  Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
51
55
  :conservative => conservative,
52
- :bundler => options[:bundler])
56
+ :bundler => update_bundler)
53
57
  end
54
58
 
55
59
  Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
@@ -66,7 +70,7 @@ module Bundler
66
70
 
67
71
  if locked_gems = Bundler.definition.locked_gems
68
72
  previous_locked_info = locked_gems.specs.reduce({}) do |h, s|
69
- h[s.name] = { :spec => s, :version => s.version, :source => s.source.to_s }
73
+ h[s.name] = { :spec => s, :version => s.version, :source => s.source.identifier }
70
74
  h
71
75
  end
72
76
  end
@@ -95,7 +99,7 @@ module Bundler
95
99
  end
96
100
 
97
101
  locked_source = locked_info[:source]
98
- new_source = new_spec.source.to_s
102
+ new_source = new_spec.source.identifier
99
103
  next if locked_source != new_source
100
104
 
101
105
  new_version = new_spec.version
data/lib/bundler/cli.rb CHANGED
@@ -61,6 +61,8 @@ module Bundler
61
61
  Bundler.reset_settings_and_root!
62
62
  end
63
63
 
64
+ Bundler.self_manager.restart_with_locked_bundler_if_needed
65
+
64
66
  Bundler.settings.set_command_option_if_given :retry, options[:retry]
65
67
 
66
68
  current_cmd = args.last[:current_command].name
@@ -184,6 +186,7 @@ module Bundler
184
186
  method_option "install", :type => :boolean, :banner =>
185
187
  "Runs 'bundle install' after removing the gems from the Gemfile"
186
188
  def remove(*gems)
189
+ SharedHelpers.major_deprecation(2, "The `--install` flag has been deprecated. `bundle install` is triggered by default.") if ARGV.include?("--install")
187
190
  require_relative "cli/remove"
188
191
  Remove.new(gems, options).run
189
192
  end
@@ -330,6 +333,7 @@ module Bundler
330
333
 
331
334
  desc "info GEM [OPTIONS]", "Show information for the given gem"
332
335
  method_option "path", :type => :boolean, :banner => "Print full path to gem"
336
+ method_option "version", :type => :boolean, :banner => "Print gem version"
333
337
  def info(gem_name)
334
338
  require_relative "cli/info"
335
339
  Info.new(options, gem_name).run
@@ -365,8 +369,11 @@ module Bundler
365
369
  method_option "version", :aliases => "-v", :type => :string
366
370
  method_option "group", :aliases => "-g", :type => :string
367
371
  method_option "source", :aliases => "-s", :type => :string
372
+ method_option "require", :aliases => "-r", :type => :string, :banner => "Adds require path to gem. Provide false, or a path as a string."
368
373
  method_option "git", :type => :string
374
+ method_option "github", :type => :string
369
375
  method_option "branch", :type => :string
376
+ method_option "ref", :type => :string
370
377
  method_option "skip-install", :type => :boolean, :banner =>
371
378
  "Adds gem to the Gemfile but does not install it"
372
379
  method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
@@ -551,7 +558,7 @@ module Bundler
551
558
  method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
552
559
  method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
553
560
  def viz
554
- SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
561
+ SharedHelpers.major_deprecation 2, "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph"
555
562
  require_relative "cli/viz"
556
563
  Viz.new(options.dup).run
557
564
  end
@@ -574,6 +581,8 @@ module Bundler
574
581
  :desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
575
582
  method_option :ci, :type => :string, :lazy_default => Bundler.settings["gem.ci"] || "",
576
583
  :desc => "Generate CI configuration, either GitHub Actions, Travis CI, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|travis|gitlab|circle)`"
584
+ method_option :linter, :type => :string, :lazy_default => Bundler.settings["gem.linter"] || "",
585
+ :desc => "Add a linter and code formatter, either RuboCop or Standard. Set a default with `bundle config set --global gem.linter (rubocop|standard)`"
577
586
  method_option :github_username, :type => :string, :default => Bundler.settings["gem.github_username"], :banner => "Set your username on GitHub", :desc => "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
578
587
 
579
588
  def gem(name)
@@ -800,17 +809,10 @@ module Bundler
800
809
 
801
810
  current = Gem::Version.new(VERSION)
802
811
  return if current >= latest
803
- latest_installed = Bundler.rubygems.find_name("bundler").map(&:version).max
804
-
805
- installation = "To install the latest version, run `gem install bundler#{" --pre" if latest.prerelease?}`"
806
- if latest_installed && latest_installed > current
807
- suggestion = "To update to the most recent installed version (#{latest_installed}), run `bundle update --bundler`"
808
- suggestion = "#{installation}\n#{suggestion}" if latest_installed < latest
809
- else
810
- suggestion = installation
811
- end
812
812
 
813
- Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}"
813
+ Bundler.ui.warn \
814
+ "The latest bundler is #{latest}, but you are currently running #{current}.\n" \
815
+ "To update to the most recent version, run `bundle update --bundler`"
814
816
  rescue RuntimeError
815
817
  nil
816
818
  end
@@ -76,15 +76,6 @@ module Bundler
76
76
  end
77
77
  end
78
78
 
79
- def specific_dependency(name, version, platform)
80
- pattern = [version, platform].compact.join("-")
81
- return nil if pattern.empty?
82
-
83
- gem_lines = info_path(name).read
84
- gem_line = gem_lines[/^#{Regexp.escape(pattern)}\b.*/, 0]
85
- gem_line ? parse_gem(gem_line) : nil
86
- end
87
-
88
79
  private
89
80
 
90
81
  def lines(path)
@@ -76,11 +76,6 @@ module Bundler
76
76
 
77
77
  update(local_path, remote_path, :retrying)
78
78
  end
79
- rescue Errno::EACCES
80
- raise Bundler::PermissionError,
81
- "Bundler does not have write access to create a temp directory " \
82
- "within #{Dir.tmpdir}. Bundler must have write access to your " \
83
- "systems temp directory to function properly. "
84
79
  rescue Zlib::GzipFile::Error
85
80
  raise Bundler::HTTPError
86
81
  end
@@ -5,7 +5,7 @@ require "set"
5
5
 
6
6
  module Bundler
7
7
  class CompactIndexClient
8
- DEBUG_MUTEX = Mutex.new
8
+ DEBUG_MUTEX = Thread::Mutex.new
9
9
  def self.debug
10
10
  return unless ENV["DEBUG_COMPACT_INDEX"]
11
11
  DEBUG_MUTEX.synchronize { warn("[#{self}] #{yield}") }
@@ -25,7 +25,7 @@ module Bundler
25
25
  @endpoints = Set.new
26
26
  @info_checksums_by_name = {}
27
27
  @parsed_checksums = false
28
- @mutex = Mutex.new
28
+ @mutex = Thread::Mutex.new
29
29
  end
30
30
 
31
31
  def execution_mode=(block)
@@ -73,12 +73,6 @@ module Bundler
73
73
  end.flatten(1)
74
74
  end
75
75
 
76
- def spec(name, version, platform = nil)
77
- Bundler::CompactIndexClient.debug { "spec(name = #{name}, version = #{version}, platform = #{platform})" }
78
- update_info(name)
79
- @cache.specific_dependency(name, version, platform)
80
- end
81
-
82
76
  def update_and_parse_checksums!
83
77
  Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" }
84
78
  return @info_checksums_by_name if @parsed_checksums
@@ -6,6 +6,11 @@ module Bundler
6
6
  class Definition
7
7
  include GemHelpers
8
8
 
9
+ class << self
10
+ # Do not create or modify a lockfile (Makes #lock a noop)
11
+ attr_accessor :no_lock
12
+ end
13
+
9
14
  attr_reader(
10
15
  :dependencies,
11
16
  :locked_deps,
@@ -73,7 +78,6 @@ module Bundler
73
78
  @lockfile_contents = String.new
74
79
  @locked_bundler_version = nil
75
80
  @locked_ruby_version = nil
76
- @locked_specs_incomplete_for_platform = false
77
81
  @new_platform = nil
78
82
 
79
83
  if lockfile && File.exist?(lockfile)
@@ -139,6 +143,8 @@ module Bundler
139
143
  @dependency_changes = converge_dependencies
140
144
  @local_changes = converge_locals
141
145
 
146
+ @locked_specs_incomplete_for_platform = !@locked_specs.for(requested_dependencies & expand_dependencies(locked_dependencies), true, true)
147
+
142
148
  @requires = compute_requires
143
149
  end
144
150
 
@@ -157,8 +163,10 @@ module Bundler
157
163
  end
158
164
  end
159
165
 
160
- def multisource_allowed?
161
- @multisource_allowed
166
+ def resolve_only_locally!
167
+ @remote = false
168
+ sources.local_only!
169
+ resolve
162
170
  end
163
171
 
164
172
  def resolve_with_cache!
@@ -222,17 +230,22 @@ module Bundler
222
230
  end
223
231
  end
224
232
 
233
+ def locked_dependencies
234
+ @locked_deps.values
235
+ end
236
+
225
237
  def specs_for(groups)
226
- groups = requested_groups if groups.empty?
238
+ return specs if groups.empty?
227
239
  deps = dependencies_for(groups)
228
- materialize(expand_dependencies(deps))
240
+ materialize(deps)
229
241
  end
230
242
 
231
243
  def dependencies_for(groups)
232
244
  groups.map!(&:to_sym)
233
- current_dependencies.reject do |d|
245
+ deps = current_dependencies.reject do |d|
234
246
  (d.groups & groups).empty?
235
247
  end
248
+ expand_dependencies(deps)
236
249
  end
237
250
 
238
251
  # Resolve all the dependencies specified in Gemfile. It ensures that
@@ -252,7 +265,7 @@ module Bundler
252
265
  else
253
266
  # Run a resolve against the locally available gems
254
267
  Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
255
- expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, @remote)
268
+ expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true)
256
269
  Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
257
270
  end
258
271
  end
@@ -267,6 +280,8 @@ module Bundler
267
280
  end
268
281
 
269
282
  def lock(file, preserve_unknown_sections = false)
283
+ return if Definition.no_lock
284
+
270
285
  contents = to_lock
271
286
 
272
287
  # Convert to \r\n if the existing lock has them
@@ -277,10 +292,7 @@ module Bundler
277
292
  locked_major = @locked_bundler_version.segments.first
278
293
  current_major = Gem::Version.create(Bundler::VERSION).segments.first
279
294
 
280
- if updating_major = locked_major < current_major
281
- Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{current_major}, " \
282
- "after which you will be unable to return to Bundler #{@locked_bundler_version.segments.first}."
283
- end
295
+ updating_major = locked_major < current_major
284
296
  end
285
297
 
286
298
  preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
@@ -297,14 +309,6 @@ module Bundler
297
309
  end
298
310
  end
299
311
 
300
- def locked_bundler_version
301
- if @locked_bundler_version && @locked_bundler_version < Gem::Version.new(Bundler::VERSION)
302
- new_version = Bundler::VERSION
303
- end
304
-
305
- new_version || @locked_bundler_version || Bundler::VERSION
306
- end
307
-
308
312
  def locked_ruby_version
309
313
  return unless ruby_version
310
314
  if @unlock[:ruby] || !@locked_ruby_version
@@ -356,44 +360,31 @@ module Bundler
356
360
  added.concat new_platforms.map {|p| "* platform: #{p}" }
357
361
  deleted.concat deleted_platforms.map {|p| "* platform: #{p}" }
358
362
 
359
- gemfile_sources = sources.lock_sources
363
+ new_deps = @dependencies - locked_dependencies
364
+ deleted_deps = locked_dependencies - @dependencies
360
365
 
361
- new_sources = gemfile_sources - @locked_sources
362
- deleted_sources = @locked_sources - gemfile_sources
363
-
364
- new_deps = @dependencies - @locked_deps.values
365
- deleted_deps = @locked_deps.values - @dependencies
366
+ added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
367
+ deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
366
368
 
367
- # Check if it is possible that the source is only changed thing
368
- if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
369
- new_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
370
- deleted_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
371
- end
369
+ both_sources = Hash.new {|h, k| h[k] = [] }
370
+ @dependencies.each {|d| both_sources[d.name][0] = d }
372
371
 
373
- if @locked_sources != gemfile_sources
374
- if new_sources.any?
375
- added.concat new_sources.map {|source| "* source: #{source}" }
376
- end
372
+ locked_dependencies.each do |d|
373
+ next if !Bundler.feature_flag.bundler_3_mode? && @locked_specs[d.name].empty?
377
374
 
378
- if deleted_sources.any?
379
- deleted.concat deleted_sources.map {|source| "* source: #{source}" }
380
- end
375
+ both_sources[d.name][1] = d
381
376
  end
382
377
 
383
- added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
384
- if deleted_deps.any?
385
- deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" }
386
- end
378
+ both_sources.each do |name, (dep, lock_dep)|
379
+ next if dep.nil? || lock_dep.nil?
387
380
 
388
- both_sources = Hash.new {|h, k| h[k] = [] }
389
- @dependencies.each {|d| both_sources[d.name][0] = d }
390
- @locked_deps.each {|name, d| both_sources[name][1] = d.source }
381
+ gemfile_source = dep.source || sources.default_source
382
+ lock_source = lock_dep.source || sources.default_source
383
+ next if lock_source.include?(gemfile_source)
391
384
 
392
- both_sources.each do |name, (dep, lock_source)|
393
- next if lock_source.nil? || (dep && lock_source.can_lock?(dep))
394
- gemfile_source_name = (dep && dep.source) || "no specified source"
395
- lockfile_source_name = lock_source
396
- changed << "* #{name} from `#{gemfile_source_name}` to `#{lockfile_source_name}`"
385
+ gemfile_source_name = dep.source ? gemfile_source.identifier : "no specified source"
386
+ lockfile_source_name = lock_dep.source ? lock_source.identifier : "no specified source"
387
+ changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
397
388
  end
398
389
 
399
390
  reason = change_reason
@@ -504,6 +495,7 @@ module Bundler
504
495
 
505
496
  def current_ruby_platform_locked?
506
497
  return false unless generic_local_platform == Gem::Platform::RUBY
498
+ return false if Bundler.settings[:force_ruby_platform] && !@platforms.include?(Gem::Platform::RUBY)
507
499
 
508
500
  current_platform_locked?
509
501
  end
@@ -554,7 +546,7 @@ module Bundler
554
546
 
555
547
  def dependencies_for_source_changed?(source, locked_source = source)
556
548
  deps_for_source = @dependencies.select {|s| s.source == source }
557
- locked_deps_for_source = @locked_deps.values.select {|dep| dep.source == locked_source }
549
+ locked_deps_for_source = locked_dependencies.select {|dep| dep.source == locked_source }
558
550
 
559
551
  deps_for_source.uniq.sort != locked_deps_for_source.sort
560
552
  end
@@ -637,25 +629,14 @@ module Bundler
637
629
  end
638
630
 
639
631
  def converge_dependencies
640
- frozen = Bundler.frozen_bundle?
641
- (@dependencies + @locked_deps.values).each do |dep|
642
- locked_source = @locked_deps[dep.name]
643
- # This is to make sure that if bundler is installing in deployment mode and
644
- # after locked_source and sources don't match, we still use locked_source.
645
- if frozen && !locked_source.nil? &&
646
- locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist?
647
- dep.source = locked_source.source
648
- elsif dep.source
632
+ changes = false
633
+
634
+ @dependencies.each do |dep|
635
+ if dep.source
649
636
  dep.source = sources.get(dep.source)
650
637
  end
651
- end
652
638
 
653
- changes = false
654
- # We want to know if all match, but don't want to check all entries
655
- # This means we need to return false if any dependency doesn't match
656
- # the lock or doesn't exist in the lock.
657
- @dependencies.each do |dependency|
658
- unless locked_dep = @locked_deps[dependency.name]
639
+ unless locked_dep = @locked_deps[dep.name]
659
640
  changes = true
660
641
  next
661
642
  end
@@ -666,11 +647,11 @@ module Bundler
666
647
  # directive, the lockfile dependencies and resolved dependencies end up
667
648
  # with a mismatch on #type. Work around that by setting the type on the
668
649
  # dep from the lockfile.
669
- locked_dep.instance_variable_set(:@type, dependency.type)
650
+ locked_dep.instance_variable_set(:@type, dep.type)
670
651
 
671
652
  # We already know the name matches from the hash lookup
672
653
  # so we only need to check the requirement now
673
- changes ||= dependency.requirement != locked_dep.requirement
654
+ changes ||= dep.requirement != locked_dep.requirement
674
655
  end
675
656
 
676
657
  changes
@@ -680,39 +661,36 @@ module Bundler
680
661
  # commonly happen if the Gemfile has changed since the lockfile was last
681
662
  # generated
682
663
  def converge_locked_specs
683
- deps = []
684
-
685
- # Build a list of dependencies that are the same in the Gemfile
686
- # and Gemfile.lock. If the Gemfile modified a dependency, but
687
- # the gem in the Gemfile.lock still satisfies it, this is fine
688
- # too.
689
- @dependencies.each do |dep|
690
- locked_dep = @locked_deps[dep.name]
664
+ resolve = converge_specs(@locked_specs)
691
665
 
692
- # If the locked_dep doesn't match the dependency we're looking for then we ignore the locked_dep
693
- locked_dep = nil unless locked_dep == dep
666
+ diff = nil
694
667
 
695
- if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep)
696
- deps << dep
697
- elsif dep.source.is_a?(Source::Path) && dep.current_platform? && (!locked_dep || dep.source != locked_dep.source)
698
- @locked_specs.each do |s|
699
- @unlock[:gems] << s.name if s.source == dep.source
700
- end
668
+ # Now, we unlock any sources that do not have anymore gems pinned to it
669
+ sources.all_sources.each do |source|
670
+ next unless source.respond_to?(:unlock!)
701
671
 
702
- dep.source.unlock! if dep.source.respond_to?(:unlock!)
703
- dep.source.specs.each {|s| @unlock[:gems] << s.name }
672
+ unless resolve.any? {|s| s.source == source }
673
+ diff ||= @locked_specs.to_a - resolve.to_a
674
+ source.unlock! if diff.any? {|s| s.source == source }
704
675
  end
705
676
  end
706
677
 
678
+ resolve
679
+ end
680
+
681
+ def converge_specs(specs)
682
+ deps = []
707
683
  converged = []
708
- @locked_specs.each do |s|
684
+ specs.each do |s|
709
685
  # Replace the locked dependency's source with the equivalent source from the Gemfile
710
686
  dep = @dependencies.find {|d| s.satisfies?(d) }
711
- s.source = (dep && dep.source) || sources.get(s.source) unless multisource_allowed?
712
687
 
713
- # Don't add a spec to the list if its source is expired. For example,
714
- # if you change a Git gem to RubyGems.
715
- next if s.source.nil?
688
+ if dep && (!dep.source || s.source.include?(dep.source))
689
+ deps << dep
690
+ end
691
+
692
+ s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source unless Bundler.frozen_bundle?
693
+
716
694
  next if @unlock[:sources].include?(s.source.name)
717
695
 
718
696
  # If the spec is from a path source and it doesn't exist anymore
@@ -725,7 +703,7 @@ module Bundler
725
703
  rescue PathError, GitError
726
704
  # if we won't need the source (according to the lockfile),
727
705
  # don't error if the path/git source isn't available
728
- next if @locked_specs.
706
+ next if specs.
729
707
  for(requested_dependencies, false, true).
730
708
  none? {|locked_spec| locked_spec.source == s.source }
731
709
 
@@ -741,36 +719,15 @@ module Bundler
741
719
  s.dependencies.replace(new_spec.dependencies)
742
720
  end
743
721
 
744
- converged << s
745
- end
746
-
747
- resolve = SpecSet.new(converged)
748
- @locked_specs_incomplete_for_platform = !resolve.for(expand_dependencies(requested_dependencies & deps), true, true)
749
- resolve = SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) })
750
- diff = nil
751
-
752
- # Now, we unlock any sources that do not have anymore gems pinned to it
753
- sources.all_sources.each do |source|
754
- next unless source.respond_to?(:unlock!)
755
-
756
- unless resolve.any? {|s| s.source == source }
757
- diff ||= @locked_specs.to_a - resolve.to_a
758
- source.unlock! if diff.any? {|s| s.source == source }
722
+ if dep.nil? && requested_dependencies.find {|d| s.name == d.name }
723
+ @unlock[:gems] << s.name
724
+ else
725
+ converged << s
759
726
  end
760
727
  end
761
728
 
762
- resolve
763
- end
764
-
765
- def in_locked_deps?(dep, locked_dep)
766
- # Because the lockfile can't link a dep to a specific remote, we need to
767
- # treat sources as equivalent anytime the locked dep has all the remotes
768
- # that the Gemfile dep does.
769
- locked_dep && locked_dep.source && dep.source && locked_dep.source.include?(dep.source)
770
- end
771
-
772
- def satisfies_locked_spec?(dep)
773
- @locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
729
+ resolve = SpecSet.new(converged)
730
+ SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) })
774
731
  end
775
732
 
776
733
  def metadata_dependencies
@@ -863,22 +820,11 @@ module Bundler
863
820
 
864
821
  def additional_base_requirements_for_resolve
865
822
  return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
866
- dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
867
- @locked_gems.specs.reduce({}) do |requirements, locked_spec|
823
+ converge_specs(@locked_gems.specs).map do |locked_spec|
868
824
  name = locked_spec.name
869
- dependency = dependencies_by_name[name]
870
- next requirements if @locked_gems.dependencies[name] != dependency
871
- next requirements if dependency && dependency.source.is_a?(Source::Path)
872
825
  dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
873
- requirements[name] = DepProxy.get_proxy(dep, locked_spec.platform)
874
- requirements
875
- end.values
876
- end
877
-
878
- def equivalent_rubygems_remotes?(source)
879
- return false unless source.is_a?(Source::Rubygems)
880
-
881
- Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
826
+ DepProxy.get_proxy(dep, locked_spec.platform)
827
+ end
882
828
  end
883
829
 
884
830
  def source_map
@@ -7,7 +7,7 @@ require_relative "rubygems_ext"
7
7
  module Bundler
8
8
  class Dependency < Gem::Dependency
9
9
  attr_reader :autorequire
10
- attr_reader :groups, :platforms, :gemfile, :git, :branch
10
+ attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref
11
11
 
12
12
  PLATFORM_MAP = {
13
13
  :ruby => Gem::Platform::RUBY,
@@ -82,7 +82,9 @@ module Bundler
82
82
  @groups = Array(options["group"] || :default).map(&:to_sym)
83
83
  @source = options["source"]
84
84
  @git = options["git"]
85
+ @github = options["github"]
85
86
  @branch = options["branch"]
87
+ @ref = options["ref"]
86
88
  @platforms = Array(options["platforms"])
87
89
  @env = options["env"]
88
90
  @should_include = options.fetch("should_include", true)
@@ -96,15 +98,11 @@ module Bundler
96
98
  def gem_platforms(valid_platforms)
97
99
  return valid_platforms if @platforms.empty?
98
100
 
99
- valid_generic_platforms = valid_platforms.map {|p| [p, GemHelpers.generic(p)] }.to_h
100
- @gem_platforms ||= expanded_platforms.compact.uniq
101
-
102
- filtered_generic_platforms = valid_generic_platforms.values & @gem_platforms
103
- valid_generic_platforms.select {|_, v| filtered_generic_platforms.include?(v) }.keys
101
+ valid_platforms.select {|p| expanded_platforms.include?(GemHelpers.generic(p)) }
104
102
  end
105
103
 
106
104
  def expanded_platforms
107
- @platforms.map {|pl| PLATFORM_MAP[pl] }
105
+ @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq
108
106
  end
109
107
 
110
108
  def should_include?