rouge-ruby/rouge · error · ArgumentError

Invalid source: #{source.inspect}

Error message

Invalid source: #{source.inspect}

What it means

Error "Invalid source: #{source.inspect}" thrown in rouge-ruby/rouge.

Source

Thrown at lib/rouge/guessers/util.rb:29

        # @return [String,nil]
        def self.normalize(source)
          source.sub(UTF8_BOM_RE, '').gsub(/\r\n/, "\n")
        end
      end

      def test_glob(pattern, path)
        File.fnmatch?(pattern, path, File::FNM_DOTMATCH | File::FNM_CASEFOLD)
      end

      # @param [String,IO] source
      # @return [String]
      def get_source(source)
        if source.respond_to?(:to_str)
          SourceNormalizer.normalize(source.to_str)
        elsif source.respond_to?(:read)
          SourceNormalizer.normalize(source.read)
        else
          raise ArgumentError, "Invalid source: #{source.inspect}"
        end
      end
    end
  end
end

View on GitHub (pinned to bd7dad7b09)

When it happens

Trigger: Thrown at lib/rouge/guessers/util.rb:29 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/f6ab64aa68cd8ef3. Report an issue: GitHub.