rouge-ruby/rouge · error · RuntimeError

invalid color: #{color.inspect}

Error message

invalid color: #{color.inspect}

What it means

Error "invalid color: #{color.inspect}" thrown in rouge-ruby/rouge.

Source

Thrown at lib/rouge/formatters/terminal_truecolor.rb:26

      class TruecolorEscapeSequence < Terminal256::EscapeSequence
        def style_string
          @style_string ||= begin
            out = String.new('')
            out << escape(['48', '2', *get_rgb(style.bg)]) if style.bg
            out << escape(['38', '2', *get_rgb(style.fg)]) if style.fg
            out << escape(['1']) if style[:bold] || style[:italic]
            out
          end
        end

        def get_rgb(color)
          color = $1 if color =~ /#(\h+)/

          case color.size
          when 3 then color.chars.map { |c| c.to_i(16) * 2 }
          when 6 then color.scan(/../).map { |cc| cc.to_i(16) }
          else
            raise "invalid color: #{color.inspect}"
          end
        end
      end

      # @override
      def make_escape_sequence(style)
        TruecolorEscapeSequence.new(style)
      end
    end
  end
end

View on GitHub (pinned to bd7dad7b09)

When it happens

Trigger: Thrown at lib/rouge/formatters/terminal_truecolor.rb:26 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rouge-ruby/rouge@bd7dad7b09 (2026-08-23). Data as JSON: /api/errors/b92db4f847c3b527. Report an issue: GitHub.