{"record":{"id":"a9b4af770660733e","repo":"jordansissel/fpm","slug":"error-trying-to-use-path-as-a-config-file-in","errorCode":null,"errorMessage":"Error trying to use '#{path}' as a config file in the package. Does it exist?","messagePattern":"Error trying to use '#(.+?)' as a config file in the package\\. Does it exist\\?","errorType":"exception","errorClass":"FPM::InvalidPackageConfiguration","httpStatus":null,"severity":"error","filePath":"lib/fpm/package/deb.rb","lineNumber":1178,"sourceCode":"        add_path(\"/etc\", etcfiles)\n      end\n    rescue Errno::ENOENT\n    end\n\n    return unless (config_files.any? or inits.any? or defaults.any? or upstarts.any? or etcfiles.any?)\n\n    allconfigs = etcfiles\n\n    # scan all conf file paths for files and add them\n    config_files.each do |path|\n      logger.debug(\"Checking if #{path} exists\")\n      cfe = File.exist?(\"#{path}\")\n      logger.debug(\"Check result #{cfe}\")\n      begin\n        add_path(path, allconfigs)\n      rescue Errno::ENOENT\n        if !cfe\n          raise FPM::InvalidPackageConfiguration,\n            \"Error trying to use '#{path}' as a config file in the package. Does it exist?\"\n        else\n          dcl = File.join(staging_path, path)\n          if !File.exist?(\"#{dcl}\")\n            logger.debug(\"Adding config file #{path} to Staging area #{staging_path}\")\n            FileUtils.mkdir_p(File.dirname(dcl))\n            FileUtils.cp_r path, dcl\n            add_path(path, allconfigs)\n          else\n            logger.debug(\"Config file aready exists in staging area.\")\n          end\n        end\n      end\n    end\n\n    if attributes[:deb_auto_config_files?]\n      inits.each do |init|\n        name = File.basename(init, \".init\")","sourceCodeStart":1160,"sourceCodeEnd":1196,"githubUrl":"https://github.com/jordansissel/fpm/blob/b6d77ba72a560b687723376a0e5115c3a92634ad/lib/fpm/package/deb.rb#L1160-L1196","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","Fix typos and use absolute paths matching what the package actually contains","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)"],"exampleFix":"# before\nfpm -s empty -t deb -n foo --config-files /etc/foo/foo.conf\n# -> Error trying to use '/etc/foo/foo.conf' as a config file\n\n# after\nmkdir -p pkgroot/etc/foo && cp foo.conf pkgroot/etc/foo/foo.conf\nfpm -s dir -t deb -n foo --config-files /etc/foo/foo.conf pkgroot","handlingStrategy":"validation","validationCode":"config_files.each do |path|\n  in_staging = File.exist?(File.join(staging_path, path))\n  on_host = File.exist?(path)\n  if !in_staging && !on_host\n    abort \"--config-files path '#{path}' exists neither in staging nor on host\"\n  end\nend","typeGuard":null,"tryCatchPattern":"begin\n  pkg.output(out)\nrescue FPM::InvalidPackageConfiguration => e\n  raise unless e.message =~ /as a config file in the package/\n  path = e.message[/'(\\/[^']+)'/, 1]\n  pkg.attributes[:deb_config_files] -= [path]   # drop the missing conffile and rebuild\n  retry\nend","preventionTips":["Only list files in --config-files that you also ship in the package payload (e.g. under /etc via -s dir input)","Use absolute paths matching the installed location exactly; avoid relative config paths","If the config file is created by a postinst script, do not list it as a conffile"],"tags":["fpm","deb","config-files","conffiles","packaging"],"backgroundTag":"file-not-found","analyzedSha":"b6d77ba72a560b687723376a0e5115c3a92634ad","analyzedAt":"2026-08-21T16:39:02.570Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}