wpscanteam/wpscan · error · OptParseValidator::NoRequiredOption

One of the following options is required: #{opt.to_long}, --

Error message

One of the following options is required: #{opt.to_long}, --#{opt.required_unless.join(', --').tr('_', '-')}

What it means

Same post_processing pass (lib/opt_parse_validator.rb:155), but for options declared with required_unless: the option itself OR at least one of the listed alternative options must appear in @results, otherwise NoRequiredOption is raised with a message enumerating all acceptable alternatives. In WPScan this is the classic --url constraint: --url is required unless a non-scan action such as --update or --version is given, so a bare 'wpscan' invocation produces exactly this error listing --url plus the alternatives.

Source

Thrown at lib/opt_parse_validator.rb:155

          raise e.is_a?(Error) ? e.class : Error, "#{opt.to_long} #{e}"
        end
      end
    end

    # Ensure that all required options are supplied
    # Should be overriden to modify the behavior
    #
    # @return [ Void ]
    def post_processing
      @opts.each do |opt|
        raise NoRequiredOption, "The option #{opt.to_long} is required" if opt.required? && !@results.key?(opt.to_sym)

        next if opt.required_unless.empty? || @results.key?(opt.to_sym)

        fail_msg = 'One of the following options is required: ' \
                   "#{opt.to_long}, --#{opt.required_unless.join(', --').tr('_', '-')}"

        raise NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|
          @results.key?(sym)
        end
      end
    end
  end
end

View on GitHub (pinned to 62c9cef471)

Solutions

  1. Add --url <target> to the command (most common fix), e.g. wpscan --url https://example.com
  2. Or use one of the alternatives listed in the message verbatim, e.g. wpscan --update or wpscan --version
  3. Or set url: in ~/.config/wpscan/scan.yml / scan.json so @results always contains it
  4. Inspect the message: every acceptable option is listed after the option name; pick one and pass it

Example fix

# before
$ wpscan
# => One of the following options is required: --url, --update, --version ...

# after
$ wpscan --url https://example.com
# or
$ wpscan --update
Defensive patterns

Strategy: try-catch

Validate before calling

# Ensure the option or one of its required_unless alternatives is supplied
needed = %i[url]
alternatives = %i[update version]
ok = (needed + alternatives).any? { |sym| argv.include?("--#{sym}") }
abort 'One of the following options is required: --url, --update, --version' unless ok

Try / catch

begin
  options = parser.results(argv)
rescue OptParseValidator::NoRequiredOption => e
  # e.message already lists every acceptable alternative; surface it verbatim
  warn e.message
  exit 64 # EX_USAGE
end

Prevention

When it happens

Trigger: Running wpscan with neither --url nor any of the alternative options (--update, --version, help flags); passing the alternative with a typo so its symbol never lands in @results; config file supplying url: but with a wrong key type (e.g. nested under another key) so required_unless.any? { |sym| @results.key?(sym) } stays false.

Common situations: New users running plain 'wpscan' expecting a menu; cron/CI jobs meant to run 'wpscan --update' that lost their flags in shell quoting; YAML indentation errors in scan.yml; wrapper scripts that conditionally build the command line and drop both branches.

Related errors


AI-assisted analysis of wpscanteam/wpscan@62c9cef471 (2026-08-21). Data as JSON: /api/errors/960076e9094d856a. Report an issue: GitHub.