jordansissel/fpm · error · FPM::InvalidPackageConfiguration

Error trying to use '#{path}' as a config file in the packag

Error message

Error trying to use '#{path}' as a config file in the package. Does it exist?

What it means

For each path given via --config-files, fpm tries to register it as a conffile by looking it up in the package (add_path). If that raises Errno::ENOENT, fpm checks whether the path exists on the build host; when it exists neither on the host nor already in staging, it raises FPM::InvalidPackageConfiguration asking whether the file exists at all.

Source

Thrown at lib/fpm/package/deb.rb:1178

        add_path("/etc", etcfiles)
      end
    rescue Errno::ENOENT
    end

    return unless (config_files.any? or inits.any? or defaults.any? or upstarts.any? or etcfiles.any?)

    allconfigs = etcfiles

    # scan all conf file paths for files and add them
    config_files.each do |path|
      logger.debug("Checking if #{path} exists")
      cfe = File.exist?("#{path}")
      logger.debug("Check result #{cfe}")
      begin
        add_path(path, allconfigs)
      rescue Errno::ENOENT
        if !cfe
          raise FPM::InvalidPackageConfiguration,
            "Error trying to use '#{path}' as a config file in the package. Does it exist?"
        else
          dcl = File.join(staging_path, path)
          if !File.exist?("#{dcl}")
            logger.debug("Adding config file #{path} to Staging area #{staging_path}")
            FileUtils.mkdir_p(File.dirname(dcl))
            FileUtils.cp_r path, dcl
            add_path(path, allconfigs)
          else
            logger.debug("Config file aready exists in staging area.")
          end
        end
      end
    end

    if attributes[:deb_auto_config_files?]
      inits.each do |init|
        name = File.basename(init, ".init")

View on GitHub (pinned to b6d77ba72a)

Solutions

  1. Stage the file first: include /etc/app/app.conf in the -s dir input tree so it exists in the package, then keep the --config-files flag
  2. Fix typos and use absolute paths matching what the package actually contains
  3. If the file is generated at install time by a maintainer script, remove it from --config-files (a non-shipped path cannot be a conffile)

Example fix

# before
fpm -s empty -t deb -n foo --config-files /etc/foo/foo.conf
# -> Error trying to use '/etc/foo/foo.conf' as a config file

# after
mkdir -p pkgroot/etc/foo && cp foo.conf pkgroot/etc/foo/foo.conf
fpm -s dir -t deb -n foo --config-files /etc/foo/foo.conf pkgroot
Defensive patterns

Strategy: validation

Validate before calling

config_files.each do |path|
  in_staging = File.exist?(File.join(staging_path, path))
  on_host = File.exist?(path)
  if !in_staging && !on_host
    abort "--config-files path '#{path}' exists neither in staging nor on host"
  end
end

Try / catch

begin
  pkg.output(out)
rescue FPM::InvalidPackageConfiguration => e
  raise unless e.message =~ /as a config file in the package/
  path = e.message[/'(\/[^']+)'/, 1]
  pkg.attributes[:deb_config_files] -= [path]   # drop the missing conffile and rebuild
  retry
end

Prevention

When it happens

Trigger: Passing --config-files with a typo, a relative path that does not resolve from cwd, or a path that only exists on the target machine (not on the build host and not in the staged payload). The conffile mechanism can only mark files that are actually part of the package.

Common situations: Deb packaging pipelines where /etc/app/app.conf is created by the postinst script at install time (never present at build time); typos or wrong absolute prefixes (/opt/foo vs /etc/foo); running fpm from a different working directory with relative config paths; -s empty builds with no staged files.

Related errors


AI-assisted analysis of jordansissel/fpm@b6d77ba72a (2026-08-21). Data as JSON: /api/errors/a9b4af770660733e. Report an issue: GitHub.