{"record":{"id":"93b14a7d62e3ec72","repo":"jordansissel/fpm","slug":"unable-to-copy-cannot-find-program-mkfifo-and-r","errorCode":null,"errorMessage":"Unable to copy. Cannot find program 'mkfifo' and Ruby is missing the 'File.mkfifo' method: #{src}","messagePattern":"Unable to copy\\. Cannot find program 'mkfifo' and Ruby is missing the 'File\\.mkfifo' method: #(.+?)","errorType":"exception","errorClass":"FPM::Util::NamedPipeCannotBeCopied","httpStatus":null,"severity":"error","filePath":"lib/fpm/util.rb","lineNumber":350,"sourceCode":"\n\n  def copy_entry(src, dst, preserve=false, remove_destination=false)\n    st = File.lstat(src)\n\n    filetype = if st.ftype == \"file\" && st.nlink > 1\n      \"hardlink\"\n    else\n      st.ftype\n    end\n\n    case filetype\n    when 'fifo'\n      if File.respond_to?(:mkfifo)\n        File.mkfifo(dst)\n      elsif program_exists?(\"mkfifo\")\n        safesystem(\"mkfifo\", dst)\n      else\n        raise NamedPipeCannotBeCopied(\"Unable to copy. Cannot find program 'mkfifo' and Ruby is missing the 'File.mkfifo' method: #{src}\")\n      end\n    when 'socket'\n      require \"socket\"\n      # In 2019, Ruby's FileUtils added this as a way to \"copy\" a unix socket.\n      # Reference: https://github.com/ruby/fileutils/pull/36/files\n      UNIXServer.new(dst).close()\n    when 'characterSpecial', 'blockSpecial'\n      raise  UnsupportedSpecialFile.new(\"File is device which fpm doesn't know how to copy (#{File.ftype(src)}): #{src}\")\n    when 'directory'\n      FileUtils.mkdir(dst) unless File.exist? dst\n    when 'hardlink'\n      # Handle hardlinks\n      # if the file with the same dev and inode has been copied already.\n      # hard link it's copy to `dst`, otherwise make an actual copy\n      known_entry = copied_entries[[st.dev, st.ino]]\n      if known_entry\n        FileUtils.ln(known_entry, dst)\n        logger.debug(\"Copying hardlink\", :src => src, :dst => dst, :link => known_entry)","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/jordansissel/fpm/blob/b6d77ba72a560b687723376a0e5115c3a92634ad/lib/fpm/util.rb#L332-L368","documentation":"While copying the input tree into staging, FIFOs (named pipes) are recreated with File.mkfifo; if the running Ruby lacks that method (it arrived in Ruby 2.3) and no external mkfifo binary is on PATH, NamedPipeCannotBeCopied is raised, naming the offending source path.","triggerScenarios":"Running fpm on Ruby < 2.3 (or an embedded Ruby built without the method) inside a minimal container without coreutils, while the staged tree contains a named pipe left by an application or build step.","commonSituations":"Legacy Ruby containers packaging app trees containing runtime fifos; ultra-slim Docker images where coreutils was pruned; exotic Rubies (Optimized/embedded builds) missing stdlib methods.","solutions":["Run a modern Ruby (>= 2.3) so File.mkfifo exists — this alone removes the need for the external binary","Otherwise ensure coreutils is installed so /usr/bin/mkfifo is on PATH","Or remove the fifo from the input tree; runtime artifacts like fifos rarely belong in a package payload"],"exampleFix":"# before: Ruby 2.2 + slim image, tree contains var/run/ctl.fifo\nfpm -s dir -t deb ./app   # => NamedPipeCannotBeCopied: ... mkfifo ...\n\n# after: modern Ruby ships File.mkfifo\nruby -v   # ensure >= 2.3, e.g. via rbenv/copy a newer image\nfpm -s dir -t deb ./app","handlingStrategy":"validation","validationCode":"require 'fpm/util'\n\ncan_stage_fifo = File.respond_to?(:mkfifo) || FPM::Util.program_in_path?('mkfifo')\nabort 'cannot stage fifos: need Ruby >= 2.3 or mkfifo in PATH' unless can_stage_fifo","typeGuard":null,"tryCatchPattern":"begin\n  pkg.input('./app')\nrescue FPM::Util::NamedPipeCannotBeCopied => e\n  warn \"fifo in input tree cannot be staged (#{e.message}); removing fifos and retrying\"\n  retry_after_removing_fifos\nend","preventionTips":["Build fpm images on Ruby 3.x so File.mkfifo is always available","Keep coreutils present even in slim images","Do not stage runtime artifacts like fifos or sockets in package payloads"],"tags":["fpm","fifo","named-pipe","ruby-version","coreutils"],"backgroundTag":"missing-executable-in-path","analyzedSha":"b6d77ba72a560b687723376a0e5115c3a92634ad","analyzedAt":"2026-08-21T16:39:02.570Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}