method
converge_locked_specs
ruby latest stable - Class:
Bundler::Definition
Method not available on this version
This method is only available on newer versions. The first available version (v2_6_3) is shown here.
converge_locked_specs()private
Remove elements from the locked specs that are expired. This will most commonly happen if the Gemfile has changed since the lockfile was last generated
# File lib/bundler/definition.rb, line 737
def converge_locked_specs
deps = []
# Build a list of dependencies that are the same in the Gemfile
# and Gemfile.lock. If the Gemfile modified a dependency, but
# the gem in the Gemfile.lock still satisfies it, this is fine
# too.
@dependencies.each do |dep|
locked_dep = @locked_deps[dep.name]
# If the locked_dep doesn't match the dependency we're looking for then we ignore the locked_dep
locked_dep = nil unless locked_dep == dep
if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep)
deps << dep
elsif dep.source.is_a?(Source::Path) && dep.current_platform? && (!locked_dep || dep.source != locked_dep.source)
@locked_specs.each do |s|
@unlock[:gems] << s.name if s.source == dep.source
end
dep.source.unlock! if dep.source.respond_to?(:unlock!)
dep.source.specs.each {|s| @unlock[:gems] << s.name }
end
end
unlock_source_unlocks_spec = Bundler.feature_flag.unlock_source_unlocks_spec?
converged = []
@locked_specs.each do |s|
# Replace the locked dependency's source with the equivalent source from the Gemfile
dep = @dependencies.find {|d| s.satisfies?(d) }
s.source = (dep && dep.source) || sources.get(s.source)
# Don't add a spec to the list if its source is expired. For example,
# if you change a Git gem to RubyGems.
next if s.source.nil?
next if @unlock[:sources].include?(s.source.name)
# XXX This is a backwards-compatibility fix to preserve the ability to
# unlock a single gem by passing its name via `--source`. See issue #3759
# TODO: delete in Bundler 2
next if unlock_source_unlocks_spec && @unlock[:sources].include?(s.name)
# If the spec is from a path source and it doesn't exist anymore
# then we unlock it.
# Path sources have special logic
if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
other_sources_specs = begin
s.source.specs
rescue PathError, GitError
# if we won't need the source (according to the lockfile),
# don't error if the path/git source isn't available
next if @locked_specs.
for(requested_dependencies, [], false, true, false).
none? {|locked_spec| locked_spec.source == s.source }
raise
end
other = other_sources_specs[s].first
# If the spec is no longer in the path source, unlock it. This
# commonly happens if the version changed in the gemspec
next unless other
deps2 = other.dependencies.select {|d| d.type != :development }
runtime_dependencies = s.dependencies.select {|d| d.type != :development }
# If the dependencies of the path source have changed, unlock it
next unless runtime_dependencies.sort == deps2.sort
end
converged << s
end
resolve = SpecSet.new(converged)
expanded_deps = expand_dependencies(deps, true)
@locked_specs_incomplete_for_platform = !resolve.for(expanded_deps, @unlock[:gems], true, true)
resolve = resolve.for(expanded_deps, @unlock[:gems], false, false, false)
diff = nil
# Now, we unlock any sources that do not have anymore gems pinned to it
sources.all_sources.each do |source|
next unless source.respond_to?(:unlock!)
unless resolve.any? {|s| s.source == source }
diff ||= @locked_specs.to_a - resolve.to_a
source.unlock! if diff.any? {|s| s.source == source }
end
end
resolve
end Related methods
- Instance methods
- add_current_platform
- add_platform
- current_dependencies
- ensure_equivalent_gemfile_and_lockfile
- find_indexed_specs
- find_resolved_spec
- gem_version_promoter
- groups
- has_local_dependencies?
- has_rubygems_remotes?
- index
- lock
- locked_bundler_version
- locked_ruby_version
- locked_ruby_version_object
- missing_specs
- missing_specs?
- new_platform?
- new_specs
- nothing_changed?
- remove_platform
- removed_specs
- requested_specs
- resolve
- resolve_remotely!
- resolve_with_cache!
- spec_git_paths
- specs
- specs_for
- to_lock
- unlocking?
- validate_platforms!
- validate_ruby!
- validate_runtime!
- Class methods
- build
- new
- Private methods
-
additional_base_requirements_for_resolve -
change_reason -
compute_requires -
concat_ruby_version_requirements -
converge_dependencies -
converge_locals -
converge_locked_specs -
converge_path_source_to_gemspec_source -
converge_path_sources_to_gemspec_sources -
converge_paths -
converge_rubygems_sources -
converge_sources -
dependencies_for_source_changed? -
double_check_for_index -
equivalent_rubygems_remotes? -
expand_dependencies -
expanded_dependencies -
extract_gem_info -
in_locked_deps? -
lockfiles_equal? -
metadata_dependencies -
pinned_spec_names -
pretty_dep -
requested_dependencies -
requested_groups -
satisfies_locked_spec? -
source_requirements -
specs_changed? -
specs_for_source_changed?