<commit_before>module Rip
  class Installer
    include Memoize

    def initialize
      @installed = {}
      @uninstalled = {}
    end

    memoize :graph
    def graph
      PackageManager.new
    end

    def install(package, parent = nil)
      if !package.exists?
        abort "#{package.name} #{package.version} not found at #{package.source}"
      end

      Dir.chdir File.join(Rip.dir, 'rip-packages') do
        begin
          graph.add_package(package, parent) unless package.meta_package?

          return if @installed[package.name]
          @installed[package.name] = package

          package.fetch
          package.unpack
          install_dependencies(package)
          run_install_hook(package)
          copy_files(package)
          cleanup(package)

        rescue VersionConflict => e
          puts e.message
          rollback
          abort "installation failed"<commit_msg>nicer message on missing dependency<commit_after>module Rip
  class Installer
    include Memoize

    def initialize
      @installed = {}
      @uninstalled = {}
    end

    memoize :graph
    def graph
      PackageManager.new
    end

    def install(package, parent = nil)
      if !package.exists?
        error = package.name
        error += " requested by #{parent} but " if parent
        error += "not found at #{package.source}"
        abort error
      end

      Dir.chdir File.join(Rip.dir, 'rip-packages') do
        begin
          graph.add_package(package, parent) unless package.meta_package?

          return if @installed[package.name]
          @installed[package.name] = package

          package.fetch
          package.unpack
          install_dependencies(package)
          run_install_hook(package)
          copy_files(package)
          cleanup(package)

        rescue VersionConflict => e
          puts e.message
          rollback
          abort "installation failed"
{'fraction_non_alphanumeric': 0.07772561293688054, 'fraction_numerical': 0.0, 'mean_word_length': 1.996875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3583858', 'n_tokens_mistral': 524, 'n_tokens_neox': 507, 'n_words': 132}