Project

General

Profile

Actions

Feature #21960

open

Improve #backtrace to not confuse terminals

Feature #21960: Improve #backtrace to not confuse terminals
1

Added by svoop (Sven Schwyn) 2 days ago. Updated about 8 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:125083]

Description

The #backtrace of exceptions are currently printed like so:

/path/to/whatever.rb:8:in `/'
/path/to/whatever.rb:8:in `show'
(...)

Most terminals recognize /path/to/whatever.rb:8 as a local file and make it clickable as "open in editor", however, some (e.g. Ghostty) include everything up to the next whitespace, in this case /path/to/whatever.rb:8:in. This is then used as an argument to open (on macOS) which will not work due to the :in part.

There are two ways to improve this:

Replace the colon with a space

Given the existence of #backtrace_locations which is better suited for programmatically working with backtrace locations, it should not break things to slightly modify the #backtrace to look like this:

/path/to/whatever.rb:8 in `/'
/path/to/whatever.rb:8 in `show'
(...)                ^^^
                     space instead of colon

Add OCS 8 sequences

OCS 8 are the <a> tag for terminal output. While many terminals support it, it might cause visual noise in logs and therefore would have to be an opt-in feature e.g. via a Ruby interpreter argument.


Related issues 2 (0 open2 closed)

Related to Ruby - Feature #14145: Proposal: Better Method#inspectClosedActions
Related to Ruby - Feature #16495: Inconsistent quotes in error messagesClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: PDF Atom