class Bundler::Resolver::Molinillo::VersionConflict - bundler-1.15.4 Documentation

# class Bundler::Resolver::Molinillo::VersionConflict

### Public Instance Methods

message() click to toggle source

    # File lib/bundler/resolver.rb, line 14
    def message
      conflicts.sort.reduce(String.new) do |o, (name, conflict)|
        o << %Q(\nBundler could not find compatible versions for gem "#{name}":\n)
        if conflict.locked_requirement
          o << %Q(  In snapshot (#{Bundler.default_lockfile.basename}):\n)
          o << %Q(    #{printable_dep(conflict.locked_requirement)}\n)
          o << %Q(\n)
        end
        o << %Q(  In Gemfile:\n)
        trees = conflict.requirement_trees

        maximal = 1.upto(trees.size).map do |size|
          trees.map(&:last).flatten(1).combination(size).to_a
        end.flatten(1).select do |deps|
          Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement)))
        end.min_by(&:size)
        trees.reject! {|t| !maximal.include?(t.last) } if maximal

        o << trees.sort_by {|t| t.reverse.map(&:name) }.map do |tree|
          t = String.new
          depth = 2
          tree.each do |req|
            t << "  " * depth << req.to_s
            unless tree.last == req
              if spec = conflict.activated_by_name[req.name]
                t << %Q( was resolved to #{spec.version}, which)
              end
              t << %Q( depends on)
            end
            t << %Q(\n)
            depth += 1
          end
          t
        end.join("\n")

        if name == "bundler"
          o << %Q(\n  Current Bundler version:\n    bundler (#{Bundler::VERSION}))
          other_bundler_required = !conflict.requirement.requirement.satisfied_by?(Gem::Version.new Bundler::VERSION)
        end

        if name == "bundler" && other_bundler_required
          o << "\n"
          o << "This Gemfile requires a different version of Bundler.\n"
          o << "Perhaps you need to update Bundler by running `gem install bundler`?\n"
        end
        if conflict.locked_requirement
          o << "\n"
          o << %Q(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
          o << %Q(the gems in your Gemfile, which may resolve the conflict.\n)
        elsif !conflict.existing
          o << "\n"
          if conflict.requirement_trees.first.size > 1
            o << "Could not find gem '#{conflict.requirement}', which is required by "
            o << "gem '#{conflict.requirement_trees.first[-2]}', in any of the sources."
          else
            o << "Could not find gem '#{conflict.requirement}' in any of the sources\n"
          end
        end
        o
      end.strip
    end

printable_dep(dep) click to toggle source

    # File lib/bundler/resolver.rb, line 6
    def printable_dep(dep)
      if dep.is_a?(Bundler::Dependency)
        DepProxy.new(dep, dep.platforms.join(", ")).to_s.strip
      else
        dep.to_s
      end
    end