jordansissel/fpm · error · FPM::Package::InvalidArgument

Invalid log level, #{v.inspect}. Must be one of: #{loglevels

Error message

Invalid log level, #{v.inspect}. Must be one of: #{loglevels.join(", ")}

What it means

The --log option validates its value (case-insensitively, after downcasing) against error, warn, info, debug and raises FPM::Package::InvalidArgument at option-parse time for anything else, aborting the run before any packaging work starts.

Source

Thrown at lib/fpm/command.rb:70

    :attribute_name => :input_type
  option ["-C", "--chdir"], "CHDIR",
    "Change directory to here before searching for files",
    :attribute_name => :chdir
  option "--prefix", "PREFIX",
    "A path to prefix files with when building the target package. This may " \
    "not be necessary for all input packages. For example, the 'gem' type " \
    "will prefix with your gem directory automatically."
  option ["-p", "--package"], "OUTPUT", "The package file path to output."
  option ["-f", "--force"], :flag, "Force output even if it will overwrite an " \
    "existing file", :default => false
  option ["-n", "--name"], "NAME", "The name to give to the package"

  loglevels = %w(error warn info debug)
  option "--log", "LEVEL", "Set the log level. Values: #{loglevels.join(", ")}.",
    :attribute_name => :log_level do |val|
    val.downcase.tap do |v|
      if !loglevels.include?(v)
        raise FPM::Package::InvalidArgument, "Invalid log level, #{v.inspect}. Must be one of: #{loglevels.join(", ")}"
      end
    end
  end # --log
  option "--verbose", :flag, "Enable verbose output"
  option "--debug", :flag, "Enable debug output"
  option "--debug-workspace", :flag, "Keep any file workspaces around for " \
    "debugging. This will disable automatic cleanup of package staging and " \
    "build paths. It will also print which directories are available."
  option ["-v", "--version"], "VERSION", "The version to give to the package",
    :default => 1.0
  option "--iteration", "ITERATION",
    "The iteration to give to the package. RPM calls this the 'release'. " \
    "FreeBSD calls it 'PORTREVISION'. Debian calls this 'debian_revision'"
  option "--epoch", "EPOCH",
    "The epoch value for this package. RPM and Debian calls this 'epoch'. " \
    "FreeBSD calls this 'PORTEPOCH'"
  option "--license", "LICENSE",
    "(optional) license name for this package"

View on GitHub (pinned to b6d77ba72a)

Solutions

  1. Use one of the four accepted levels (any case): --log error|warn|info|debug
  2. If the flag came from an options file, fix that line in the file
  3. Remember --verbose and --debug are separate boolean flags, not --log values

Example fix

# before
fpm --log verbose -s dir -t deb ./app

# after
fpm --log debug -s dir -t deb ./app
Defensive patterns

Strategy: validation

Validate before calling

levels = %w[error warn info debug]
level = ENV.fetch('FPM_LOG_LEVEL', 'info')
raise ArgumentError, "invalid log level #{level}; use #{levels.join('|')}" unless levels.include?(level.downcase)
system('fpm', '--log', level, '-s', 'dir', '-t', 'deb', './app')

Try / catch

begin
  FPM::Command.run(%w[--log verbose -s dir -t deb .])
rescue FPM::Package::InvalidArgument => e
  warn "bad fpm flag value: #{e.message}"
end

Prevention

When it happens

Trigger: Passing 'fpm --log verbose', '--log trace', or '--log warning' (the accepted level is 'warn'); a bad value inside a --fpm-options-file file; wrapper scripts templating the level from a variable that resolves to an unsupported word.

Common situations: Confusing --log levels with --verbose/--debug flags; carrying a 'verbose' habit over from other CLIs; options files shared across teams drifting to invalid values.

Related errors


AI-assisted analysis of jordansissel/fpm@b6d77ba72a (2026-08-21). Data as JSON: /api/errors/d14854ecc4deda28. Report an issue: GitHub.