From: "alanwu (Alan Wu) via ruby-core" Date: 2026-06-05T20:00:08+00:00 Subject: [ruby-core:125627] [Ruby Feature#21960] Improve #backtrace to not confuse terminals Issue #21960 has been updated by alanwu (Alan Wu). mame (Yusuke Endoh) wrote in #note-10: > I have to be blunt: this proposal asks us to break backward compatibility based on an unverified assumption. No one has demonstrated that it actually fixes anything. All pain, no gain. I strongly oppose making this change until Ghostty's `file:line` story is settled and someone can show a concrete improvement. I also don't see replacing the colon with a space as a clear win. As people have said in the Ghostty discussion, there is just no standard for the format. The OSC 8 route might be viable, as there is a way to limit the blast radius without changing the text. We could add it for to-tty exception printouts, around check_highlight_keyword() who checks rb_stderr_tty_p(). And, maybe limit the addition to only the stock implementation of Exception#full_message. Terminals only started adding support for OSC 8 [around 4 years ago](https://github.com/Alhadis/OSC8-Adoption), but hopefully older terminals have the smarts to drop unrecognized OSC sequences without scrambling the output. ---------------------------------------- Feature #21960: Improve #backtrace to not confuse terminals https://bugs.ruby-lang.org/issues/21960#change-117478 * Author: svoop (Sven Schwyn) * Status: Open ---------------------------------------- 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](https://github.com/Alhadis/OSC8-Adoption) are the `` 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. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/