{"record":{"id":"fec0d1e591b88a13","repo":"jordansissel/fpm","slug":"tried-to-treat-readable-path-like-a-directory","errorCode":null,"errorMessage":"Tried to treat #{readable_path} like a directory, but it's a file!","messagePattern":"Tried to treat #(.+?) like a directory, but it's a file!","errorType":"exception","errorClass":"FPM::InvalidPackageConfiguration","httpStatus":null,"severity":"error","filePath":"lib/fpm/package/dir.rb","lineNumber":179,"sourceCode":"\n  # Copy a path.\n  #\n  # Files will be hardlinked if possible, but copied otherwise.\n  # Symlinks should be copied as symlinks.\n  def copy(source, destination)\n    logger.debug(\"Copying path\", :source => source, :destination => destination)\n    directory = File.dirname(destination)\n    # lstat to follow symlinks\n    dstat = File.stat(directory) rescue nil\n    if dstat.nil?\n      FileUtils.mkdir_p(directory, :mode => 0755)\n    elsif dstat.directory?\n      # do nothing, it's already a directory!\n    else\n      # It exists and is not a directory. This is probably a user error or a bug.\n      readable_path = directory.gsub(staging_path, \"\")\n      logger.error(\"You wanted to copy a file into a directory, but that's not a directory, it's a file!\", :path => readable_path, :stat => dstat)\n      raise FPM::InvalidPackageConfiguration, \"Tried to treat #{readable_path} like a directory, but it's a file!\"\n    end\n\n    if File.directory?(source)\n      if !File.symlink?(source)\n        # Create a directory if this path is a directory\n        logger.debug(\"Creating\", :directory => destination)\n        if !File.directory?(destination)\n          FileUtils.mkdir(destination)\n        end\n      else\n        # Linking symlinked directories causes a hardlink to be created, which\n        # results in the source directory being wiped out during cleanup,\n        # so copy the symlink.\n        logger.debug(\"Copying symlinked directory\", :source => source,\n                      :destination => destination)\n        FileUtils.copy_entry(source, destination)\n      end\n    else","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/jordansissel/fpm/blob/b6d77ba72a560b687723376a0e5115c3a92634ad/lib/fpm/package/dir.rb#L161-L197","documentation":"Error \"Tried to treat #{readable_path} like a directory, but it's a file!\" thrown in jordansissel/fpm.","triggerScenarios":"Thrown at lib/fpm/package/dir.rb:179 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b6d77ba72a560b687723376a0e5115c3a92634ad","analyzedAt":"2026-08-21T16:39:02.570Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}