puppetlabs/puppet · error · IniParseError

Cannot read nonexistent file

Error message

Cannot read nonexistent file %{file}

What it means

Raised as IniParseError by Puppet::Util::IniConfig::PhysicalFile#read (lib/puppet/util/inifile.rb:140) when the underlying flat filetype read returns nil, meaning the configured INI file does not exist (or is unreadable such that its content is nil). The reader cannot parse a nonexistent file, so it aborts with the inspected path in %{file}.

Solutions

  1. Create the INI file %{file} before code that reads it, or make reading conditional on File.exist?.
  2. Correct the configured file path if it points to the wrong location.
  3. Check permissions if the file exists but cannot be read.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at lib/puppet/util/inifile.rb:140 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/d4b0dc86f1ec43c9. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/util/inifile.rb:140

    attr_accessor :destroy_empty

    # @!attribute [rw] file_collection
    #   @return [Puppet::Util::IniConfig::FileCollection]
    attr_accessor :file_collection

    def initialize(file, options = {})
      @file = file
      @contents = []
      @filetype = Puppet::Util::FileType.filetype(:flat).new(file)

      @destroy_empty = options.fetch(:destroy_empty, false)
    end

    # Read and parse the on-disk file associated with this object
    def read
      text = @filetype.read
      if text.nil?
        raise IniParseError, _("Cannot read nonexistent file %{file}") % { file: @file.inspect }
      end

      parse(text)
    end

    INI_COMMENT = Regexp.union(
      /^\s*$/,
      /^[#;]/,
      /^\s*rem\s/i
    )
    INI_CONTINUATION = /^[ \t\r\n\f]/
    INI_SECTION_NAME = /^\[([^\]]+)\]/
    INI_PROPERTY     = /^\s*([^\s=]+)\s*=\s*(.*)$/

    # @api private
    def parse(text)
      section = nil   # The name of the current section
      optname = nil   # The name of the last option in section

View on GitHub (pinned to e227c27540)