Fri Oct 03 12:13:00 UTC 2008

rexml/formatters/pretty.rb:131:in `wrap': stack level too deep (SystemStackError)

Posted in Rails at 12:13 PM by matt

Getting rexml/formatters/pretty.rb:131:in `wrap': stack level too deep (SystemStackError) ? I recommend monkey patching that file with the following basically, find the two methods below, and add what you don't see in the source file.
def initialize( indentation=2, ie_hack=false )
        @indentation = indentation
        @level = 0
        @ie_hack = ie_hack
        @width = 80
        @stack_level = 0
end

def wrap(string, width)
  # Recursively wrap string at width.
  @stack_level = @stack_level + 1
  if @stack_level >= 1200
    return string + '...'
  end
  return string if string.length <= width
  place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
  if place
    return string[0,place] + "\n" + wrap(string[place+1..-1], width)
  else
    return string # cannot wrap
  end
end

Leave a Comment