jordansissel/fpm · error · FPM::Package::InvalidArgument
The given workdir '#{workdir}' does not exist.
Error message
The given workdir '#{workdir}' does not exist. What it means
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.
Source
Thrown at lib/fpm/command.rb:306
end
if (stray_flags = args.grep(/^-/); stray_flags.any?)
logger.warn("All flags should be before the first argument " \
"(stray flags found: #{stray_flags}")
end
# Some older behavior, if you specify:
# 'fpm -s dir -t ... -C somepath'
# fpm would assume you meant to add '.' to the end of the commandline.
# Let's hack that. https://github.com/jordansissel/fpm/issues/187
if input_type == "dir" and args.empty? and !chdir.nil?
logger.info("No args, but -s dir and -C are given, assuming '.' as input")
args << "."
end
if !File.exist?(workdir)
logger.fatal("Given --workdir=#{workdir} is not a path that exists.")
raise FPM::Package::InvalidArgument, "The given workdir '#{workdir}' does not exist."
end
if !File.directory?(workdir)
logger.fatal("Given --workdir=#{workdir} must be a directory")
raise FPM::Package::InvalidArgument, "The given workdir '#{workdir}' must be a directory."
end
logger.info("Setting workdir", :workdir => workdir)
ENV["TMP"] = workdir
validator = Validator.new(self)
if !validator.ok?
validator.messages.each do |message|
logger.warn(message)
end
logger.fatal("Fix the above problems, and you'll be rolling packages in no time!")
return 1
endView on GitHub (pinned to b6d77ba72a)
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
Example fix
# before fpm --workdir /tmp/fpm-build -s dir -t deb ./app # dir missing # after mkdir -p /tmp/fpm-build && fpm --workdir /tmp/fpm-build -s dir -t deb ./app
Defensive patterns
Strategy: validation
Validate before calling
require 'fileutils'
workdir = File.expand_path('/tmp/fpm-build')
FileUtils.mkdir_p(workdir)
system('fpm', '--workdir', workdir, '-s', 'dir', '-t', 'deb', './app') Try / catch
begin
FPM::Command.run(argv)
rescue FPM::Package::InvalidArgument => e
abort "fix --workdir: #{e.message}"
end Prevention
- mkdir -p the workdir at the start of the build script
- Use absolute --workdir paths
- Make workspace-setup steps unconditional in CI pipelines
When it happens
Trigger: 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.
Common situations: CI workspaces where setup steps are conditional; typos in the flag value; scripts run from a different working directory than assumed.
Related errors
- The given workdir '#{workdir}' must be a directory.
- Invalid log level, #{v.inspect}. Must be one of: #{loglevels
- Options file given to --fpm-options-file is seems too large.
- pear
- #{program}
AI-assisted analysis of jordansissel/fpm@b6d77ba72a (2026-08-21).
Data as JSON: /api/errors/ebb9a5558d71665e.
Report an issue: GitHub.