pry/pry · error · InvalidCommandError

Unknown command `#{items[0]}`

Error message

Unknown command `#{items[0]}`

What it means

Error "Unknown command `#{items[0]}`" thrown in pry/pry.

Source

Thrown at lib/pry/slop/commands.rb:146

      def parse(items = ARGV)
        parse! items.dup
        items
      end

      # Parse a list of items, removing any options or option arguments found.
      #
      # items - The Array of items to parse.
      #
      # Returns the original Array of items with options removed.
      def parse!(items = ARGV)
        if (opts = commands[items[0].to_s])
          @triggered_command = items.shift
          execute_arguments! items
          opts.parse! items
        elsif (opts = commands['default'])
          opts.parse! items
        elsif config[:strict] && items[0]
          raise InvalidCommandError, "Unknown command `#{items[0]}`"
        end
        execute_global_opts! items
        items
      end

      # Returns a nested Hash with Slop options and values. See Slop#to_hash.
      def to_hash
        Hash[commands.map { |k, v| [k.to_sym, v.to_hash] }]
      end

      # Returns the help String.
      def to_s
        defaults = commands.delete('default')
        globals = commands.delete('global')
        helps = commands.reject { |_, v| v.options.none? }
        helps['Global options'] = globals.to_s if globals && globals.options.any?
        helps['Other options'] = defaults.to_s if defaults && defaults.options.any?
        banner = @banner ? "#{@banner}\n" : ""

View on GitHub (pinned to 1356402628)

When it happens

Trigger: Thrown at lib/pry/slop/commands.rb:146 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pry/pry@1356402628 (2026-08-21). Data as JSON: /api/errors/1a97d8abac47b4ef. Report an issue: GitHub.