bundler 2.2.12 → 2.2.14

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c743279657baa7fb86bcbe8b49fe758261f53161679c28c0d9d4251f7c32626
4
- data.tar.gz: 127f8571d11fd6f22612ee988bb6abec9035cfa9df65949994255253b4c108b7
3
+ metadata.gz: 31f2f45fcc46844af7ae85151dd04e9ddd20b8daaee6999b735813bc632b5e28
4
+ data.tar.gz: 9fe8d309077af1c3d82794d8e020037b788995038c90674885ccb61ff595d4da
5
5
  SHA512:
6
- metadata.gz: 284b277cfa1bdd0d99da2eef27a8ea3ae97c2e4f0ca1b6622bb276fdf7f9de4e46c44f3aaffc94328569df7057c6cb1dd091702f35b5a2bb808764df708b9c14
7
- data.tar.gz: 606a3cbbbb7186a5fdfc8a6c68f9f50cba4e8634506f8a7fba8ff4fbdbae0013f8e551a2f9d97980a20c781f79ef542c9d664cf84b6a029e3649349a27260422
6
+ metadata.gz: 55a040289f2f69a734b222d30fdd716e1789c8a2d18519dd225d16fa4e418748cab1f850888b290f92305fc8e07b02e30a8816ed756d0877ef7f286e6ec2393b
7
+ data.tar.gz: c810e53e037eec801da65b145ff9ef34d556df32b128086c5f6242b228dc9a6df3595d23aae8f1513a410e54666adc23be8d152a3790346fa4ca97feb51c394b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # 2.2.14 (March 8, 2021)
2
+
3
+ ## Security fixes:
4
+
5
+ - Lock GEM sources separately and fix locally installed specs confusing bundler [#4381](https://github.com/rubygems/rubygems/pull/4381)
6
+
7
+ ## Bug fixes:
8
+
9
+ - Make `rake` available to other gems' installers right after it's installed [#4428](https://github.com/rubygems/rubygems/pull/4428)
10
+ - Fix encoding issue on compact index updater [#4362](https://github.com/rubygems/rubygems/pull/4362)
11
+
12
+ # 2.2.13 (March 3, 2021)
13
+
14
+ ## Enhancements:
15
+
16
+ - Respect user configured default branch in README links in new generated gems [#4303](https://github.com/rubygems/rubygems/pull/4303)
17
+
18
+ ## Bug fixes:
19
+
20
+ - Fix gems sometimes being pulled from irrelevant sources [#4418](https://github.com/rubygems/rubygems/pull/4418)
21
+
1
22
  # 2.2.12 (March 1, 2021)
2
23
 
3
24
  ## Bug fixes:
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2021-03-01".freeze
8
- @git_commit_sha = "1de3f8de73".freeze
7
+ @built_at = "2021-03-08".freeze
8
+ @git_commit_sha = "3a169d80c1".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -39,11 +39,11 @@ module Bundler
39
39
  constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
40
40
  constant_array = constant_name.split("::")
41
41
 
42
- git_installed = Bundler.git_present?
42
+ use_git = Bundler.git_present? && options[:git]
43
43
 
44
- git_author_name = git_installed ? `git config user.name`.chomp : ""
45
- github_username = git_installed ? `git config github.user`.chomp : ""
46
- git_user_email = git_installed ? `git config user.email`.chomp : ""
44
+ git_author_name = use_git ? `git config user.name`.chomp : ""
45
+ github_username = use_git ? `git config github.user`.chomp : ""
46
+ git_user_email = use_git ? `git config user.email`.chomp : ""
47
47
 
48
48
  config = {
49
49
  :name => name,
@@ -58,6 +58,7 @@ module Bundler
58
58
  :ext => options[:ext],
59
59
  :exe => options[:exe],
60
60
  :bundler_version => bundler_dependency_version,
61
+ :git => use_git,
61
62
  :github_username => github_username.empty? ? "[USERNAME]" : github_username,
62
63
  :required_ruby_version => Gem.ruby_version < Gem::Version.new("2.4.a") ? "2.3.0" : "2.4.0",
63
64
  }
@@ -79,7 +80,7 @@ module Bundler
79
80
  bin/setup
80
81
  ]
81
82
 
82
- templates.merge!("gitignore.tt" => ".gitignore") if Bundler.git_present?
83
+ templates.merge!("gitignore.tt" => ".gitignore") if use_git
83
84
 
84
85
  if test_framework = ask_and_set_test_framework
85
86
  config[:test] = test_framework
@@ -175,24 +176,31 @@ module Bundler
175
176
  )
176
177
  end
177
178
 
179
+ if File.exist?(target) && !File.directory?(target)
180
+ Bundler.ui.error "Couldn't create a new gem named `#{gem_name}` because there's an existing file named `#{gem_name}`."
181
+ exit Bundler::BundlerError.all_errors[Bundler::GenericSystemCallError]
182
+ end
183
+
184
+ if use_git
185
+ Bundler.ui.info "Initializing git repo in #{target}"
186
+ `git init #{target}`
187
+
188
+ config[:git_default_branch] = File.read("#{target}/.git/HEAD").split("/").last.chomp
189
+ end
190
+
178
191
  templates.each do |src, dst|
179
192
  destination = target.join(dst)
180
- SharedHelpers.filesystem_access(destination) do
181
- thor.template("newgem/#{src}", destination, config)
182
- end
193
+ thor.template("newgem/#{src}", destination, config)
183
194
  end
184
195
 
185
196
  executables.each do |file|
186
- SharedHelpers.filesystem_access(target.join(file)) do |path|
187
- executable = (path.stat.mode | 0o111)
188
- path.chmod(executable)
189
- end
197
+ path = target.join(file)
198
+ executable = (path.stat.mode | 0o111)
199
+ path.chmod(executable)
190
200
  end
191
201
 
192
- if Bundler.git_present? && options[:git]
193
- Bundler.ui.info "Initializing git repo in #{target}"
202
+ if use_git
194
203
  Dir.chdir(target) do
195
- `git init`
196
204
  `git add .`
197
205
  end
198
206
  end
@@ -202,8 +210,6 @@ module Bundler
202
210
 
203
211
  Bundler.ui.info "Gem '#{name}' was successfully created. " \
204
212
  "For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html"
205
- rescue Errno::EEXIST => e
206
- raise GenericSystemCallError.new(e, "There was a conflict while creating the new gem.")
207
213
  end
208
214
 
209
215
  private
@@ -54,7 +54,7 @@ module Bundler
54
54
  if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
55
55
  local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
56
56
  else
57
- local_temp_path.open("w") {|f| f << content }
57
+ local_temp_path.open("wb") {|f| f << content }
58
58
  end
59
59
  end
60
60
 
@@ -106,6 +106,17 @@ module Bundler
106
106
  @locked_platforms = []
107
107
  end
108
108
 
109
+ @locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
110
+ @disable_multisource = @locked_gem_sources.all?(&:disable_multisource?)
111
+
112
+ unless @disable_multisource
113
+ msg = "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. You should run `bundle update` or generate your lockfile from scratch."
114
+
115
+ Bundler::SharedHelpers.major_deprecation 2, msg
116
+
117
+ @sources.merged_gem_lockfile_sections!
118
+ end
119
+
109
120
  @unlock[:gems] ||= []
110
121
  @unlock[:sources] ||= []
111
122
  @unlock[:ruby] ||= if @ruby_version && locked_ruby_version_object
@@ -145,6 +156,10 @@ module Bundler
145
156
  end
146
157
  end
147
158
 
159
+ def disable_multisource?
160
+ @disable_multisource
161
+ end
162
+
148
163
  def resolve_with_cache!
149
164
  raise "Specs already loaded" if @specs
150
165
  sources.cached!
@@ -264,7 +279,7 @@ module Bundler
264
279
  # Run a resolve against the locally available gems
265
280
  Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
266
281
  expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, @remote)
267
- Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
282
+ Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
268
283
  end
269
284
  end
270
285
  end
@@ -530,6 +545,9 @@ module Bundler
530
545
  attr_reader :sources
531
546
  private :sources
532
547
 
548
+ attr_reader :locked_gem_sources
549
+ private :locked_gem_sources
550
+
533
551
  def nothing_changed?
534
552
  !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@locked_specs_incomplete_for_platform
535
553
  end
@@ -654,21 +672,20 @@ module Bundler
654
672
  end
655
673
 
656
674
  def converge_rubygems_sources
657
- return false if Bundler.feature_flag.disable_multisource?
675
+ return false if disable_multisource?
658
676
 
659
- changes = false
677
+ return false if locked_gem_sources.empty?
660
678
 
661
- # Get the RubyGems sources from the Gemfile.lock
662
- locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
663
679
  # Get the RubyGems remotes from the Gemfile
664
680
  actual_remotes = sources.rubygems_remotes
681
+ return false if actual_remotes.empty?
682
+
683
+ changes = false
665
684
 
666
685
  # If there is a RubyGems source in both
667
- if !locked_gem_sources.empty? && !actual_remotes.empty?
668
- locked_gem_sources.each do |locked_gem|
669
- # Merge the remotes from the Gemfile into the Gemfile.lock
670
- changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
671
- end
686
+ locked_gem_sources.each do |locked_gem|
687
+ # Merge the remotes from the Gemfile into the Gemfile.lock
688
+ changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
672
689
  end
673
690
 
674
691
  changes
@@ -893,30 +910,18 @@ module Bundler
893
910
  # Record the specs available in each gem's source, so that those
894
911
  # specs will be available later when the resolver knows where to
895
912
  # look for that gemspec (or its dependencies)
896
- default = sources.default_source
897
- source_requirements = { :default => default }
898
- default = nil unless Bundler.feature_flag.disable_multisource?
899
- dependencies.each do |dep|
900
- next unless source = dep.source || default
901
- source_requirements[dep.name] = source
902
- end
913
+ source_requirements = { :default => sources.default_source }.merge(dependency_source_requirements)
903
914
  metadata_dependencies.each do |dep|
904
915
  source_requirements[dep.name] = sources.metadata_source
905
916
  end
917
+ source_requirements[:global] = index unless Bundler.feature_flag.disable_multisource?
906
918
  source_requirements[:default_bundler] = source_requirements["bundler"] || source_requirements[:default]
907
919
  source_requirements["bundler"] = sources.metadata_source # needs to come last to override
908
920
  source_requirements
909
921
  end
910
922
 
911
923
  def pinned_spec_names(skip = nil)
912
- pinned_names = []
913
- default = Bundler.feature_flag.disable_multisource? && sources.default_source
914
- @dependencies.each do |dep|
915
- next unless dep_source = dep.source || default
916
- next if dep_source == skip
917
- pinned_names << dep.name
918
- end
919
- pinned_names
924
+ dependency_source_requirements.reject {|_, source| source == skip }.keys
920
925
  end
921
926
 
922
927
  def requested_groups
@@ -973,5 +978,17 @@ module Bundler
973
978
 
974
979
  Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
975
980
  end
981
+
982
+ def dependency_source_requirements
983
+ @dependency_source_requirements ||= begin
984
+ source_requirements = {}
985
+ default = sources.default_source
986
+ dependencies.each do |dep|
987
+ dep_source = dep.source || default
988
+ source_requirements[dep.name] = dep_source
989
+ end
990
+ source_requirements
991
+ end
992
+ end
976
993
  end
977
994
  end
data/lib/bundler/dsl.rb CHANGED
@@ -24,6 +24,9 @@ module Bundler
24
24
  def initialize
25
25
  @source = nil
26
26
  @sources = SourceList.new
27
+
28
+ @global_rubygems_sources = []
29
+
27
30
  @git_sources = {}
28
31
  @dependencies = []
29
32
  @groups = []
@@ -45,6 +48,7 @@ module Bundler
45
48
  @gemfiles << expanded_gemfile_path
46
49
  contents ||= Bundler.read_file(@gemfile.to_s)
47
50
  instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
51
+ check_primary_source_safety
48
52
  rescue Exception => e # rubocop:disable Lint/RescueException
49
53
  message = "There was an error " \
50
54
  "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
@@ -164,8 +168,7 @@ module Bundler
164
168
  elsif block_given?
165
169
  with_source(@sources.add_rubygems_source("remotes" => source), &blk)
166
170
  else
167
- check_primary_source_safety(@sources)
168
- @sources.global_rubygems_source = source
171
+ @global_rubygems_sources << source
169
172
  end
170
173
  end
171
174
 
@@ -183,24 +186,14 @@ module Bundler
183
186
  end
184
187
 
185
188
  def path(path, options = {}, &blk)
186
- unless block_given?
187
- msg = "You can no longer specify a path source by itself. Instead, \n" \
188
- "either use the :path option on a gem, or specify the gems that \n" \
189
- "bundler should find in the path source by passing a block to \n" \
190
- "the path method, like: \n\n" \
191
- " path 'dir/containing/rails' do\n" \
192
- " gem 'rails'\n" \
193
- " end\n\n"
194
-
195
- raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource?
196
- SharedHelpers.major_deprecation(2, msg.strip)
197
- end
198
-
199
189
  source_options = normalize_hash(options).merge(
200
190
  "path" => Pathname.new(path),
201
191
  "root_path" => gemfile_root,
202
192
  "gemspec" => gemspecs.find {|g| g.name == options["name"] }
203
193
  )
194
+
195
+ source_options["global"] = true unless block_given?
196
+
204
197
  source = @sources.add_path_source(source_options)
205
198
  with_source(source, &blk)
206
199
  end
@@ -279,6 +272,11 @@ module Bundler
279
272
  raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile"
280
273
  end
281
274
 
275
+ def check_primary_source_safety
276
+ check_path_source_safety
277
+ check_rubygems_source_safety
278
+ end
279
+
282
280
  private
283
281
 
284
282
  def add_git_sources
@@ -440,25 +438,38 @@ repo_name ||= user_name
440
438
  end
441
439
  end
442
440
 
443
- def check_primary_source_safety(source_list)
444
- return if source_list.rubygems_primary_remotes.empty? && source_list.global_rubygems_source.nil?
441
+ def check_path_source_safety
442
+ return if @sources.global_path_source.nil?
443
+
444
+ msg = "You can no longer specify a path source by itself. Instead, \n" \
445
+ "either use the :path option on a gem, or specify the gems that \n" \
446
+ "bundler should find in the path source by passing a block to \n" \
447
+ "the path method, like: \n\n" \
448
+ " path 'dir/containing/rails' do\n" \
449
+ " gem 'rails'\n" \
450
+ " end\n\n"
451
+
452
+ SharedHelpers.major_deprecation(2, msg.strip)
453
+ end
454
+
455
+ def check_rubygems_source_safety
456
+ @sources.global_rubygems_source = @global_rubygems_sources.shift
457
+ return if @global_rubygems_sources.empty?
445
458
 
446
- if Bundler.feature_flag.disable_multisource?
459
+ @global_rubygems_sources.each do |source|
460
+ @sources.add_rubygems_remote(source)
461
+ end
462
+
463
+ if Bundler.feature_flag.bundler_3_mode?
447
464
  msg = "This Gemfile contains multiple primary sources. " \
448
465
  "Each source after the first must include a block to indicate which gems " \
449
466
  "should come from that source"
450
- unless Bundler.feature_flag.bundler_2_mode?
451
- msg += ". To downgrade this error to a warning, run " \
452
- "`bundle config unset disable_multisource`"
453
- end
454
467
  raise GemfileEvalError, msg
455
468
  else
456
469
  Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \
457
470
  "Using `source` more than once without a block is a security risk, and " \
458
471
  "may result in installing unexpected gems. To resolve this warning, use " \
459
- "a block to indicate which gems should come from the secondary source. " \
460
- "To upgrade this warning to an error, run `bundle config set --local " \
461
- "disable_multisource true`."
472
+ "a block to indicate which gems should come from the secondary source."
462
473
  end
463
474
  end
464
475
 
@@ -50,6 +50,7 @@ def gemfile(install = false, options = {}, &gemfile)
50
50
  Bundler::Plugin.gemfile_install(&gemfile) if Bundler.feature_flag.plugins?
51
51
  builder = Bundler::Dsl.new
52
52
  builder.instance_eval(&gemfile)
53
+ builder.check_primary_source_safety
53
54
 
54
55
  Bundler.settings.temporary(:frozen => false) do
55
56
  definition = builder.to_definition(nil, true)
@@ -27,13 +27,8 @@ module Bundler
27
27
  state == :failed
28
28
  end
29
29
 
30
- def installation_attempted?
31
- installed? || failed?
32
- end
33
-
34
- # Only true when spec in neither installed nor already enqueued
35
30
  def ready_to_enqueue?
36
- !enqueued? && !installation_attempted?
31
+ state == :none
37
32
  end
38
33
 
39
34
  def has_post_install_message?
@@ -93,6 +88,11 @@ module Bundler
93
88
  def call
94
89
  check_for_corrupt_lockfile
95
90
 
91
+ if @rake
92
+ do_install(@rake, 0)
93
+ Gem::Specification.reset
94
+ end
95
+
96
96
  if @size > 1
97
97
  install_with_worker
98
98
  else
@@ -217,8 +217,6 @@ module Bundler
217
217
  # are installed.
218
218
  def enqueue_specs
219
219
  @specs.select(&:ready_to_enqueue?).each do |spec|
220
- next if @rake && !@rake.installed? && spec.name != @rake.name
221
-
222
220
  if spec.dependencies_installed? @specs
223
221
  spec.state = :enqueued
224
222
  worker_pool.enq spec
@@ -64,8 +64,6 @@ module Bundler
64
64
  @state = nil
65
65
  @specs = {}
66
66
 
67
- @rubygems_aggregate = Source::Rubygems.new
68
-
69
67
  if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
70
68
  raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
71
69
  "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
@@ -89,7 +87,6 @@ module Bundler
89
87
  send("parse_#{@state}", line)
90
88
  end
91
89
  end
92
- @sources << @rubygems_aggregate unless Bundler.feature_flag.disable_multisource?
93
90
  @specs = @specs.values.sort_by(&:identifier)
94
91
  warn_for_outdated_bundler_version
95
92
  rescue ArgumentError => e
@@ -134,16 +131,9 @@ module Bundler
134
131
  @sources << @current_source
135
132
  end
136
133
  when GEM
137
- if Bundler.feature_flag.disable_multisource?
138
- @opts["remotes"] = @opts.delete("remote")
139
- @current_source = TYPES[@type].from_lock(@opts)
140
- @sources << @current_source
141
- else
142
- Array(@opts["remote"]).each do |url|
143
- @rubygems_aggregate.add_remote(url)
144
- end
145
- @current_source = @rubygems_aggregate
146
- end
134
+ @opts["remotes"] = Array(@opts.delete("remote")).reverse
135
+ @current_source = TYPES[@type].from_lock(@opts)
136
+ @sources << @current_source
147
137
  when PLUGIN
148
138
  @current_source = Plugin.source_from_lock(@opts)
149
139
  @sources << @current_source
@@ -105,6 +105,7 @@ module Bundler
105
105
  else
106
106
  builder.eval_gemfile(gemfile)
107
107
  end
108
+ builder.check_primary_source_safety
108
109
  definition = builder.to_definition(nil, true)
109
110
 
110
111
  return if definition.dependencies.empty?
@@ -140,6 +140,13 @@ module Bundler
140
140
  end
141
141
  end
142
142
 
143
+ # Set internal representation to fetch the gems/specs locally.
144
+ #
145
+ # When this is called, the source should try to fetch the specs and
146
+ # install from the local system.
147
+ def local!
148
+ end
149
+
143
150
  # Set internal representation to fetch the gems/specs from remote.
144
151
  #
145
152
  # When this is called, the source should try to fetch the specs and
@@ -16,15 +16,13 @@ module Bundler
16
16
 
17
17
  version = options[:version] || [">= 0"]
18
18
 
19
- Bundler.settings.temporary(:disable_multisource => false) do
20
- if options[:git]
21
- install_git(names, version, options)
22
- elsif options[:local_git]
23
- install_local_git(names, version, options)
24
- else
25
- sources = options[:source] || Bundler.rubygems.sources
26
- install_rubygems(names, version, sources)
27
- end
19
+ if options[:git]
20
+ install_git(names, version, options)
21
+ elsif options[:local_git]
22
+ install_local_git(names, version, options)
23
+ else
24
+ sources = options[:source] || Bundler.rubygems.sources
25
+ install_rubygems(names, version, sources)
28
26
  end
29
27
  end
30
28
 
@@ -79,7 +77,7 @@ module Bundler
79
77
  source_list = SourceList.new
80
78
 
81
79
  source_list.add_git_source(git_source_options) if git_source_options
82
- source_list.add_rubygems_source("remotes" => rubygems_source) if rubygems_source
80
+ source_list.global_rubygems_source = rubygems_source if rubygems_source
83
81
 
84
82
  deps = names.map {|name| Dependency.new name, version }
85
83
 
@@ -17,6 +17,10 @@ module Bundler
17
17
  path_sources + git_sources + rubygems_sources + [metadata_source]
18
18
  end
19
19
 
20
+ def default_source
21
+ git_sources.first || global_rubygems_source
22
+ end
23
+
20
24
  private
21
25
 
22
26
  def rubygems_aggregate_class
@@ -17,16 +17,21 @@ module Bundler
17
17
  # ==== Returns
18
18
  # <GemBundle>,nil:: If the list of dependencies can be resolved, a
19
19
  # collection of gemspecs is returned. Otherwise, nil is returned.
20
- def self.resolve(requirements, index, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil)
20
+ def self.resolve(requirements, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil)
21
21
  base = SpecSet.new(base) unless base.is_a?(SpecSet)
22
- resolver = new(index, source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
22
+ resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
23
23
  result = resolver.start(requirements)
24
24
  SpecSet.new(result)
25
25
  end
26
26
 
27
- def initialize(index, source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
28
- @index = index
27
+ def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
29
28
  @source_requirements = source_requirements
29
+
30
+ @index_requirements = source_requirements.each_with_object({}) do |source_requirement, index_requirements|
31
+ name, source = source_requirement
32
+ index_requirements[name] = name == :global ? source : source.specs
33
+ end
34
+
30
35
  @base = base
31
36
  @resolver = Molinillo::Resolver.new(self, self)
32
37
  @search_for = {}
@@ -40,7 +45,7 @@ module Bundler
40
45
  @resolving_only_for_ruby = platforms == [Gem::Platform::RUBY]
41
46
  @gem_version_promoter = gem_version_promoter
42
47
  @use_gvp = Bundler.feature_flag.use_gem_version_promoter_for_major_updates? || !@gem_version_promoter.major?
43
- @lockfile_uses_separate_rubygems_sources = Bundler.feature_flag.disable_multisource?
48
+ @no_aggregate_global_source = @source_requirements[:global].nil?
44
49
 
45
50
  @variant_specific_names = []
46
51
  @generic_names = ["Ruby\0", "RubyGems\0"]
@@ -125,8 +130,7 @@ module Bundler
125
130
  dependency = dependency_proxy.dep
126
131
  name = dependency.name
127
132
  search_result = @search_for[dependency_proxy] ||= begin
128
- index = index_for(dependency)
129
- results = index.search(dependency, @base[name])
133
+ results = results_for(dependency, @base[name])
130
134
 
131
135
  if vertex = @base_dg.vertex_named(name)
132
136
  locked_requirement = vertex.payload.requirement
@@ -196,22 +200,22 @@ module Bundler
196
200
  end
197
201
 
198
202
  def index_for(dependency)
199
- source = @source_requirements[dependency.name]
203
+ source = @index_requirements[dependency.name]
200
204
  if source
201
- source.specs
202
- elsif @lockfile_uses_separate_rubygems_sources
205
+ source
206
+ elsif @no_aggregate_global_source
203
207
  Index.build do |idx|
204
- if dependency.all_sources
205
- dependency.all_sources.each {|s| idx.add_source(s.specs) if s }
206
- else
207
- idx.add_source @source_requirements[:default].specs
208
- end
208
+ dependency.all_sources.each {|s| idx.add_source(s.specs) }
209
209
  end
210
210
  else
211
- @index
211
+ @index_requirements[:global]
212
212
  end
213
213
  end
214
214
 
215
+ def results_for(dependency, base)
216
+ index_for(dependency).search(dependency, base)
217
+ end
218
+
215
219
  def name_for(dependency)
216
220
  dependency.name
217
221
  end
@@ -239,18 +243,20 @@ module Bundler
239
243
  def relevant_sources_for_vertex(vertex)
240
244
  if vertex.root?
241
245
  [@source_requirements[vertex.name]]
242
- elsif @lockfile_uses_separate_rubygems_sources
246
+ elsif @no_aggregate_global_source
243
247
  vertex.recursive_predecessors.map do |v|
244
248
  @source_requirements[v.name]
245
- end << @source_requirements[:default]
249
+ end.compact << @source_requirements[:default]
250
+ else
251
+ []
246
252
  end
247
253
  end
248
254
 
249
255
  def sort_dependencies(dependencies, activated, conflicts)
250
256
  dependencies.sort_by do |dependency|
251
- dependency.all_sources = relevant_sources_for_vertex(activated.vertex_named(dependency.name))
252
257
  name = name_for(dependency)
253
258
  vertex = activated.vertex_named(name)
259
+ dependency.all_sources = relevant_sources_for_vertex(vertex)
254
260
  [
255
261
  @base_dg.vertex_named(name) ? 0 : 1,
256
262
  vertex.payload ? 0 : 1,
@@ -317,7 +323,7 @@ module Bundler
317
323
  "If you are updating multiple gems in your Gemfile at once,\n" \
318
324
  "try passing them all to `bundle update`"
319
325
  elsif source = @source_requirements[name]
320
- specs = source.specs[name]
326
+ specs = source.specs.search(name)
321
327
  versions_with_platforms = specs.map {|s| [s.version, s.platform] }
322
328
  message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source}#{cache_message}.\n")
323
329
  message << if versions_with_platforms.any?
@@ -326,7 +332,7 @@ module Bundler
326
332
  "The source does not contain any versions of '#{name}'"
327
333
  end
328
334
  else
329
- message = "Could not find gem '#{requirement}' in any of the gem sources " \
335
+ message = "Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in any of the gem sources " \
330
336
  "listed in your Gemfile#{cache_message}."
331
337
  end
332
338
  raise GemNotFound, message
@@ -392,7 +398,7 @@ module Bundler
392
398
  if other_bundler_required
393
399
  o << "\n\n"
394
400
 
395
- candidate_specs = @source_requirements[:default_bundler].specs.search(conflict_dependency)
401
+ candidate_specs = @index_requirements[:default_bundler].search(conflict_dependency)
396
402
  if candidate_specs.any?
397
403
  target_version = candidate_specs.last.version
398
404
  new_command = [File.basename($PROGRAM_NAME), "_#{target_version}_", *ARGV].join(" ")
@@ -411,14 +417,8 @@ module Bundler
411
417
 
412
418
  relevant_sources = if conflict.requirement.source
413
419
  [conflict.requirement.source]
414
- elsif conflict.requirement.all_sources
415
- conflict.requirement.all_sources
416
- elsif @lockfile_uses_separate_rubygems_sources
417
- # every conflict should have an explicit group of sources when we
418
- # enforce strict pinning
419
- raise "no source set for #{conflict}"
420
420
  else
421
- []
421
+ conflict.requirement.all_sources
422
422
  end.compact.map(&:to_s).uniq.sort
423
423
 
424
424
  metadata_requirement = name.end_with?("\0")
@@ -455,23 +455,21 @@ module Bundler
455
455
  def validate_resolved_specs!(resolved_specs)
456
456
  resolved_specs.each do |v|
457
457
  name = v.name
458
- next unless sources = relevant_sources_for_vertex(v)
459
- sources.compact!
458
+ sources = relevant_sources_for_vertex(v)
459
+ next unless sources.any?
460
460
  if default_index = sources.index(@source_requirements[:default])
461
461
  sources.delete_at(default_index)
462
462
  end
463
- sources.reject! {|s| s.specs[name].empty? }
463
+ sources.reject! {|s| s.specs.search(name).empty? }
464
464
  sources.uniq!
465
465
  next if sources.size <= 1
466
466
 
467
- multisource_disabled = Bundler.feature_flag.disable_multisource?
468
-
469
467
  msg = ["The gem '#{name}' was found in multiple relevant sources."]
470
468
  msg.concat sources.map {|s| " * #{s}" }.sort
471
- msg << "You #{multisource_disabled ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
469
+ msg << "You #{@no_aggregate_global_source ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
472
470
  msg = msg.join("\n")
473
471
 
474
- raise SecurityError, msg if multisource_disabled
472
+ raise SecurityError, msg if @no_aggregate_global_source
475
473
  Bundler.ui.warn "Warning: #{msg}"
476
474
  end
477
475
  end
@@ -33,6 +33,12 @@ module Bundler
33
33
  spec.source == self
34
34
  end
35
35
 
36
+ def local!; end
37
+
38
+ def cached!; end
39
+
40
+ def remote!; end
41
+
36
42
  # it's possible that gems from one source depend on gems from some
37
43
  # other source, so now we download gemspecs and iterate over those
38
44
  # dependencies, looking for gems we don't have info on yet.
@@ -33,10 +33,6 @@ module Bundler
33
33
  end
34
34
  end
35
35
 
36
- def cached!; end
37
-
38
- def remote!; end
39
-
40
36
  def options
41
37
  {}
42
38
  end
@@ -20,17 +20,29 @@ module Bundler
20
20
  @dependency_names = []
21
21
  @allow_remote = false
22
22
  @allow_cached = false
23
+ @allow_local = options["allow_local"] || false
23
24
  @caches = [cache_path, *Bundler.rubygems.gem_cache]
24
25
 
25
- Array(options["remotes"] || []).reverse_each {|r| add_remote(r) }
26
+ Array(options["remotes"]).reverse_each {|r| add_remote(r) }
27
+ end
28
+
29
+ def local!
30
+ return if @allow_local
31
+
32
+ @specs = nil
33
+ @allow_local = true
26
34
  end
27
35
 
28
36
  def remote!
37
+ return if @allow_remote
38
+
29
39
  @specs = nil
30
40
  @allow_remote = true
31
41
  end
32
42
 
33
43
  def cached!
44
+ return if @allow_cached
45
+
34
46
  @specs = nil
35
47
  @allow_cached = true
36
48
  end
@@ -49,8 +61,12 @@ module Bundler
49
61
  o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty?
50
62
  end
51
63
 
64
+ def disable_multisource?
65
+ @remotes.size <= 1
66
+ end
67
+
52
68
  def can_lock?(spec)
53
- return super if Bundler.feature_flag.disable_multisource?
69
+ return super if disable_multisource?
54
70
  spec.source.is_a?(Rubygems)
55
71
  end
56
72
 
@@ -87,7 +103,7 @@ module Bundler
87
103
  # small_idx.use large_idx.
88
104
  idx = @allow_remote ? remote_specs.dup : Index.new
89
105
  idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
90
- idx.use(installed_specs, :override_dupes)
106
+ idx.use(installed_specs, :override_dupes) if @allow_local
91
107
  idx
92
108
  end
93
109
  end
@@ -365,7 +381,7 @@ module Bundler
365
381
 
366
382
  def cached_specs
367
383
  @cached_specs ||= begin
368
- idx = installed_specs.dup
384
+ idx = @allow_local ? installed_specs.dup : Index.new
369
385
 
370
386
  Dir["#{cache_path}/*.gem"].each do |gemfile|
371
387
  next if gemfile =~ /^bundler\-[\d\.]+?\.gem/
@@ -5,24 +5,40 @@ module Bundler
5
5
  attr_reader :path_sources,
6
6
  :git_sources,
7
7
  :plugin_sources,
8
- :global_rubygems_source,
8
+ :global_path_source,
9
9
  :metadata_source
10
10
 
11
+ def global_rubygems_source
12
+ @global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true)
13
+ end
14
+
11
15
  def initialize
12
16
  @path_sources = []
13
17
  @git_sources = []
14
18
  @plugin_sources = []
15
19
  @global_rubygems_source = nil
16
- @rubygems_aggregate = rubygems_aggregate_class.new
20
+ @global_path_source = nil
17
21
  @rubygems_sources = []
18
22
  @metadata_source = Source::Metadata.new
23
+
24
+ @disable_multisource = true
25
+ end
26
+
27
+ def disable_multisource?
28
+ @disable_multisource
29
+ end
30
+
31
+ def merged_gem_lockfile_sections!
32
+ @disable_multisource = false
19
33
  end
20
34
 
21
35
  def add_path_source(options = {})
22
36
  if options["gemspec"]
23
37
  add_source_to_list Source::Gemspec.new(options), path_sources
24
38
  else
25
- add_source_to_list Source::Path.new(options), path_sources
39
+ path_source = add_source_to_list Source::Path.new(options), path_sources
40
+ @global_path_source ||= path_source if options["global"]
41
+ path_source
26
42
  end
27
43
  end
28
44
 
@@ -41,24 +57,20 @@ module Bundler
41
57
  end
42
58
 
43
59
  def global_rubygems_source=(uri)
44
- if Bundler.feature_flag.disable_multisource?
45
- @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri)
46
- end
47
- add_rubygems_remote(uri)
60
+ @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri, "allow_local" => true)
48
61
  end
49
62
 
50
63
  def add_rubygems_remote(uri)
51
- return if Bundler.feature_flag.disable_multisource?
52
- @rubygems_aggregate.add_remote(uri)
53
- @rubygems_aggregate
64
+ global_rubygems_source.add_remote(uri)
65
+ global_rubygems_source
54
66
  end
55
67
 
56
68
  def default_source
57
- global_rubygems_source || @rubygems_aggregate
69
+ global_path_source || global_rubygems_source
58
70
  end
59
71
 
60
72
  def rubygems_sources
61
- @rubygems_sources + [default_source]
73
+ @rubygems_sources + [global_rubygems_source]
62
74
  end
63
75
 
64
76
  def rubygems_remotes
@@ -75,7 +87,7 @@ module Bundler
75
87
 
76
88
  def lock_sources
77
89
  lock_sources = (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
78
- if Bundler.feature_flag.disable_multisource?
90
+ if disable_multisource?
79
91
  lock_sources + rubygems_sources.sort_by(&:to_s)
80
92
  else
81
93
  lock_sources << combine_rubygems_sources
@@ -92,12 +104,11 @@ module Bundler
92
104
  end
93
105
  end
94
106
 
95
- replacement_rubygems = !Bundler.feature_flag.disable_multisource? &&
107
+ replacement_rubygems = !disable_multisource? &&
96
108
  replacement_sources.detect {|s| s.is_a?(Source::Rubygems) }
97
- @rubygems_aggregate = replacement_rubygems if replacement_rubygems
109
+ @global_rubygems_source = replacement_rubygems if replacement_rubygems
98
110
 
99
111
  return true if !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
100
- return true if replacement_rubygems && rubygems_remotes.sort_by(&:to_s) != replacement_rubygems.remotes.sort_by(&:to_s)
101
112
 
102
113
  false
103
114
  end
@@ -110,10 +121,6 @@ module Bundler
110
121
  all_sources.each(&:remote!)
111
122
  end
112
123
 
113
- def rubygems_primary_remotes
114
- @rubygems_aggregate.remotes
115
- end
116
-
117
124
  private
118
125
 
119
126
  def rubygems_aggregate_class
@@ -82,6 +82,7 @@ module Bundler
82
82
  materialized.map! do |s|
83
83
  next s unless s.is_a?(LazySpecification)
84
84
  s.source.dependency_names = deps if s.source.respond_to?(:dependency_names=)
85
+ s.source.local!
85
86
  spec = s.__materialize__
86
87
  unless spec
87
88
  unless missing_specs
@@ -102,6 +103,7 @@ module Bundler
102
103
  @specs.map do |s|
103
104
  next s unless s.is_a?(LazySpecification)
104
105
  s.source.dependency_names = names if s.source.respond_to?(:dependency_names=)
106
+ s.source.local!
105
107
  s.source.remote!
106
108
  spec = s.__materialize__
107
109
  raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
@@ -29,19 +29,21 @@ TODO: Write usage instructions here
29
29
  After checking out the repo, run `bin/setup` to install dependencies.<% if config[:test] %> Then, run `rake <%= config[:test].sub('mini', '').sub('rspec', 'spec') %>` to run the tests.<% end %> You can also run `bin/console` for an interactive prompt that will allow you to experiment.<% if config[:bin] %> Run `bundle exec <%= config[:name] %>` to use the gem in this directory, ignoring other installed copies of this gem.<% end %>
30
30
 
31
31
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+ <% if config[:git] -%>
32
33
 
33
34
  ## Contributing
34
35
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/<%= config[:github_username] %>/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md).<% end %>
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/<%= config[:github_username] %>/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/<%= config[:git_default_branch] %>/CODE_OF_CONDUCT.md).<% end %>
37
+ <% end -%>
36
38
  <% if config[:mit] -%>
37
39
 
38
40
  ## License
39
41
 
40
42
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
43
  <% end -%>
42
- <% if config[:coc] -%>
44
+ <% if config[:git] && config[:coc] -%>
43
45
 
44
46
  ## Code of Conduct
45
47
 
46
- Everyone interacting in the <%= config[:constant_name] %> project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md).
48
+ Everyone interacting in the <%= config[:constant_name] %> project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/<%= config[:git_default_branch] %>/CODE_OF_CONDUCT.md).
47
49
  <% end -%>
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.2.12".freeze
4
+ VERSION = "2.2.14".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.12
4
+ version: 2.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Arko
@@ -22,7 +22,7 @@ authors:
22
22
  autorequire:
23
23
  bindir: exe
24
24
  cert_chain: []
25
- date: 2021-03-01 00:00:00.000000000 Z
25
+ date: 2021-03-08 00:00:00.000000000 Z
26
26
  dependencies: []
27
27
  description: Bundler manages an application's dependencies through its entire life,
28
28
  across many machines, systematically and repeatably
@@ -352,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
352
352
  - !ruby/object:Gem::Version
353
353
  version: 2.5.2
354
354
  requirements: []
355
- rubygems_version: 3.2.12
355
+ rubygems_version: 3.2.14
356
356
  signing_key:
357
357
  specification_version: 4
358
358
  summary: The best way to manage your application's dependencies