puppetlabs/puppet · error · ArgumentError

Option %{name} is inconsistent about taking an argument

Error message

Option %{name} is inconsistent about taking an argument

What it means

Error "Option %{name} is inconsistent about taking an argument" thrown in puppetlabs/puppet.

Source

Thrown at lib/puppet/interface/option.rb:68

        raise ArgumentError, _("%{option} is not valid for an option argument") % { option: item.inspect }
      end
    end

    if @optparse.empty? then
      raise ArgumentError, _("No option declarations found while building")
    end

    # Now, infer the name from the options; we prefer the first long option as
    # the name, rather than just the first option.
    @name = optparse_to_name(@optparse.find do |a| a =~ /^--/ end || @optparse.first)
    @aliases = @optparse.map { |o| optparse_to_name(o) }

    # Do we take an argument?  If so, are we consistent about it, because
    # incoherence here makes our life super-difficult, and we can more easily
    # relax this rule later if we find a valid use case for it. --daniel 2011-03-30
    @argument = @optparse.any? { |o| o =~ /[ =]/ }
    if @argument and !@optparse.all? { |o| o =~ /[ =]/ } then
      raise ArgumentError, _("Option %{name} is inconsistent about taking an argument") % { name: @name }
    end

    # Is our argument optional?  The rules about consistency apply here, also,
    # just like they do to taking arguments at all. --daniel 2011-03-30
    @optional_argument = @optparse.any? { |o| o =~ /[ =]\[/ }
    if @optional_argument
      raise ArgumentError, _("Options with optional arguments are not supported")
    end
    if @optional_argument and !@optparse.all? { |o| o =~ /[ =]\[/ } then
      raise ArgumentError, _("Option %{name} is inconsistent about the argument being optional") % { name: @name }
    end
  end

  # to_s and optparse_to_name are roughly mirrored, because they are used to
  # transform options to name symbols, and vice-versa.  This isn't a full
  # bidirectional transformation though. --daniel 2011-04-07

  def to_s

View on GitHub (pinned to e227c27540)

When it happens

Trigger: Thrown at lib/puppet/interface/option.rb:68 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/f4154c5b29ca3238. Report an issue: GitHub.