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

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

### Public Instance Methods

clean_req(req) click to toggle source

    # File lib/bundler/resolver.rb, line 15
    def clean_req(req)
      if req.to_s.include?(">= 0")
        req.to_s.gsub(/ \(.*?\)$/, '')
      else
        req.to_s.gsub(/\, (runtime|development)\)$/, ')')
      end
    end

message() click to toggle source

    # File lib/bundler/resolver.rb, line 23
    def message
      conflicts.values.flatten.reduce('') do |o, conflict|
        o << %Q(Bundler could not find compatible versions for gem "#{conflict.requirement.name}":\n)
        if conflict.locked_requirement
          o << %Q(  In snapshot (Gemfile.lock):\n)
          o << %Q(    #{clean_req conflict.locked_requirement}\n)
          o << %Q(\n)
        end
        o << %Q(  In Gemfile:\n)
        o << conflict.requirement_trees.map do |tree|
          t = ''
          depth = 2
          tree.each do |req|
            t << '  ' * depth << %Q(#{clean_req req})
            t << %Q( depends on) unless tree[-1] == req
            t << %Q(\n)
            depth += 1
          end
          t
        end.join("\n")

        if conflict.requirement.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 conflict.requirement.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
          if conflict.requirement_trees.first.size > 1
            o << "Could not find gem '#{clean_req(conflict.requirement)}', which is required by "
            o << "gem '#{clean_req(conflict.requirement_trees.first[-2])}', in any of the sources."
          else
            o << "Could not find gem '#{clean_req(conflict.requirement)} in any of the sources\n"
          end
        end
        o
      end
    end