So let’s say you are, for example, upgrading your Rails app and when you boot it you get a crash with a mysterious “SystemStackError: stack level too deep” message. Problem is, you get no stacktrace on a stack level too deep. You know the problem is somewhere your your app’s boot-up, but you don’t know where.
My colleague found this little life-saver which I thought I’d document. Put this at the top of your application.rb and you’ll get ruby to print everything it requires as it loads your app, pinpointing exactly where the stack level too deep problem is.
module Kernel
def require_and_print(string)
puts string
require_original(string)
end
alias_method :require_original, :require
alias_method :require, :require_and_print
end
def require_and_print(string)
puts string
require_original(string)
end
alias_method :require_original, :require
alias_method :require, :require_and_print
end
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?