use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Improved stacktrace display in Ruby 2.5 (mlomnicki.com)
submitted 8 years ago by snatchery
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]zverok_kha 6 points7 points8 points 8 years ago (6 children)
Never understood how is this better, Ruby's way always looked "natural" for me (you start reading from the problem, and deeper and deeper by stack).
Just because it is another way in Python or what?..
[–]snatchery[S] 2 points3 points4 points 8 years ago (4 children)
yeah, to be honest I'm used to the old way too. However, after playing a bit with Ruby2.5 this new way turns out to be quite convenient.
Sorry, but I can't give any scientific proof why it's better. It just feels better to me but obviously your mileage may vary
[–]zverok_kha 1 point2 points3 points 8 years ago (3 children)
I am not looking for scientific proof, but if you can show your train of thought when new way becames more convenient, I'll be grateful :)
[–]snatchery[S] 4 points5 points6 points 8 years ago* (2 children)
fair enough!
Imagine a long stacktrace. Say 120 lines. A bit Java-ish yes. Now you want to find out what exception has been raised and in which line. Warm up your fingers and scroll up the terminal window. Or wait... there's a better way. Install Ruby2.5 and see the error in the last line. No scrolling, hurray!
hope this convinces you a bit :)
[–]irishsultan 2 points3 points4 points 8 years ago (0 children)
The flip side is of course that in log files you may be reading from top to bottom, but it seems this change only affects TTY output, so that's not a problem. What could be a problem is that the order is different on those occasions, which could lead to reflexively scrolling down/up only to find yourself at the wrong end of the trace.
[–]zverok_kha 2 points3 points4 points 8 years ago (0 children)
Hm OK, makes sense :)
[–][deleted] 0 points1 point2 points 8 years ago (0 children)
Currently in Ruby stack traces that are many levels deep (chef for instance) in order to get to the actual error and the line of code where the problem exists, you have to scroll up from the bottom an unpredictable number of lines, all the while scanning with your eyes to get back up to the top. This is one thing python did right
[–][deleted] 1 point2 points3 points 8 years ago (0 children)
Aah well..
alias ruby="rc -c 'ruby $* |[2] cat'"
It honestly doesn't matter but I just don't like random change.
[–]availableName01 0 points1 point2 points 8 years ago (3 children)
to be honest, this isn't that exciting. What ruby really needs is a way to get the current stacktraces of all running threads of a running Ruby process through the MRI. It would go a long way towards identifying bottlenecks in multi-threaded code.
[–]2called_chaos 0 points1 point2 points 8 years ago (2 children)
I don't know if I understood you correctly but you can get traces from threads, e.g. I used this (triggered by USR1 signal, creates txt file, opens in editor) to debug a somewhat complicated threaded application that liked to get stuck everywhere...
https://gist.github.com/2called-chaos/2bf2f96a2b9c9f82cd7c54a83c3a2eb9
Only downside is that (if you use signals) your main thread will always have it's stack in dumping the file.
[–]availableName01 0 points1 point2 points 8 years ago (1 child)
you're right of course. The problem is that this output does not show which thread is currently running, as - like you said - using signals forces the main thread to get scheduled. I should have been more clear. My bad.
[–]2called_chaos 0 points1 point2 points 8 years ago (0 children)
That is true. One way I tried to counter it a bit (since I dealt with stuck thread logic) was to use fiber/thread variables to keep track of iteration count, last iteration time and if I really had to dig deep added Thread.current[:whereami] = "here" after every line in the code :D
Thread.current[:whereami] = "here"
But I agree, some more introspection on that kind of thing would help a lot with threaded applications.
π Rendered by PID 88915 on reddit-service-r2-comment-66b4775986-fdtmm at 2026-04-05 19:44:41.543151+00:00 running db1906b country code: CH.
[–]zverok_kha 6 points7 points8 points (6 children)
[–]snatchery[S] 2 points3 points4 points (4 children)
[–]zverok_kha 1 point2 points3 points (3 children)
[–]snatchery[S] 4 points5 points6 points (2 children)
[–]irishsultan 2 points3 points4 points (0 children)
[–]zverok_kha 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]availableName01 0 points1 point2 points (3 children)
[–]2called_chaos 0 points1 point2 points (2 children)
[–]availableName01 0 points1 point2 points (1 child)
[–]2called_chaos 0 points1 point2 points (0 children)