{"record":{"id":"ebb9a5558d71665e","repo":"jordansissel/fpm","slug":"the-given-workdir-workdir-does-not-exist","errorCode":null,"errorMessage":"The given workdir '#{workdir}' does not exist.","messagePattern":"The given workdir '#(.+?)' does not exist\\.","errorType":"validation","errorClass":"FPM::Package::InvalidArgument","httpStatus":null,"severity":"error","filePath":"lib/fpm/command.rb","lineNumber":306,"sourceCode":"    end\n\n    if (stray_flags = args.grep(/^-/); stray_flags.any?)\n      logger.warn(\"All flags should be before the first argument \" \\\n                   \"(stray flags found: #{stray_flags}\")\n    end\n\n    # Some older behavior, if you specify:\n    #   'fpm -s dir -t ... -C somepath'\n    # fpm would assume you meant to add '.' to the end of the commandline.\n    # Let's hack that. https://github.com/jordansissel/fpm/issues/187\n    if input_type == \"dir\" and args.empty? and !chdir.nil?\n      logger.info(\"No args, but -s dir and -C are given, assuming '.' as input\")\n      args << \".\"\n    end\n\n    if !File.exist?(workdir)\n      logger.fatal(\"Given --workdir=#{workdir} is not a path that exists.\")\n      raise FPM::Package::InvalidArgument, \"The given workdir '#{workdir}' does not exist.\"\n    end\n    if !File.directory?(workdir)\n      logger.fatal(\"Given --workdir=#{workdir} must be a directory\")\n      raise FPM::Package::InvalidArgument, \"The given workdir '#{workdir}' must be a directory.\"\n    end\n\n    logger.info(\"Setting workdir\", :workdir => workdir)\n    ENV[\"TMP\"] = workdir\n\n    validator = Validator.new(self)\n    if !validator.ok?\n      validator.messages.each do |message|\n        logger.warn(message)\n      end\n\n      logger.fatal(\"Fix the above problems, and you'll be rolling packages in no time!\")\n      return 1\n    end","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/jordansissel/fpm/blob/b6d77ba72a560b687723376a0e5115c3a92634ad/lib/fpm/command.rb#L288-L324","documentation":"The --workdir path must already exist: fpm validates existence before assigning the directory to ENV['TMP'] for package staging. A non-existent path logs a fatal message and raises FPM::Package::InvalidArgument with the given path.","triggerScenarios":"Running 'fpm --workdir /tmp/fpm-build ...' before creating that directory; a relative --workdir resolved from a different cwd in CI; the directory normally created by an earlier pipeline step that was skipped or failed.","commonSituations":"CI workspaces where setup steps are conditional; typos in the flag value; scripts run from a different working directory than assumed.","solutions":["Create the directory up front: mkdir -p <workdir> in the build script","Use an absolute --workdir path to avoid cwd-dependent resolution","Make the directory-creation step unconditional in pipelines"],"exampleFix":"# before\nfpm --workdir /tmp/fpm-build -s dir -t deb ./app   # dir missing\n\n# after\nmkdir -p /tmp/fpm-build && fpm --workdir /tmp/fpm-build -s dir -t deb ./app","handlingStrategy":"validation","validationCode":"require 'fileutils'\n\nworkdir = File.expand_path('/tmp/fpm-build')\nFileUtils.mkdir_p(workdir)\nsystem('fpm', '--workdir', workdir, '-s', 'dir', '-t', 'deb', './app')","typeGuard":null,"tryCatchPattern":"begin\n  FPM::Command.run(argv)\nrescue FPM::Package::InvalidArgument => e\n  abort \"fix --workdir: #{e.message}\"\nend","preventionTips":["mkdir -p the workdir at the start of the build script","Use absolute --workdir paths","Make workspace-setup steps unconditional in CI pipelines"],"tags":["fpm","cli","workdir","path","argument-validation"],"backgroundTag":"path-not-found","analyzedSha":"b6d77ba72a560b687723376a0e5115c3a92634ad","analyzedAt":"2026-08-21T16:39:02.570Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}