Feature #16495
closedInconsistent quotes in error messages
Added by Kolano (Kenneth Kolano) over 4 years ago. Updated 6 months ago.
Description
Error messages use inconsistent pairs of quotes, for instance:
-e:1:in `<main>': undefined local variable or method `foo' for main:Object (NameError)
where a back tick is used on the left-hand side, and a single quote is used on the right.
The same quotes should be used on either side of the elements being quoted.
Updated by jeremyevans0 (Jeremy Evans) over 4 years ago
- Tracker changed from Bug to Feature
- ruby -v deleted (
2.5.3) - Backport deleted (
2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN)
Updated by shevegen (Robert A. Heiler) over 4 years ago
Hmm. Is this encoding-related perhaps? I remember having had that when I used ISO (ISO-8859-1 specifically, and
a non-utf locale too). Nowadays, with Unicode, I don't seem to have this inconsistent quote - but I understand
what you refer to. I used to think that it was used to denote the start, and end part of the content. :P
(They are not the same characters in general right? Otherwise they would appear the same. I always thought it
may be some standard, perhaps to make parsing easier or something.)
Never bothered me that much to really investigate, though.
Updated by nobu (Nobuyoshi Nakada) over 4 years ago
This combination is very common, e.g., Emacs, TeX, etc.
Updated by mame (Yusuke Endoh) over 4 years ago
- Related to Bug #12321: Backticks in log output cause issues added
Updated by mame (Yusuke Endoh) over 4 years ago
- Related to Bug #13589: unmatched opening backtick / closing quote in NoMethodError: undefined method `name' for {}:Hash added
Updated by sawa (Tsuyoshi Sawada) over 4 years ago
- Subject changed from Inconsistant Quotes in Error Messages to Inconsistent quotes in error messages
- Description updated (diff)
Updated by matz (Yukihiro Matsumoto) over 4 years ago
It was something cultural. I admit nowadays very few people use backquote as a left-hand quote, but it used to be. I also admit consistent quotes are easier for our eyes when using recent major fonts. But changing those quotes may affect existing log parsers. We have to estimate how big is the influence of the changes.
Matz.
Updated by Dan0042 (Daniel DeLorme) over 4 years ago
Maybe a fix could involve customization of which quotes to display via an ENV var or something?
Instead of changing the code all over the place you'd just be changing e.g. rb_sprintf
to replace matching sets of ` and ' to use the custom quotes.
So it would be possible to dynamically set the quotes to ' and ' (or even unicode ‘ and ’) if you don't use log parsers that rely on the regular behavior.
Log parsers could eventually use these custom quotes for their parsing.
It would be possible for individuals to gradually experiment and report bugs where custom quote are causing trouble.
Just an idea...
Updated by marcandre (Marc-Andre Lafortune) over 4 years ago
- Assignee set to matz (Yukihiro Matsumoto)
I fail to see the actual gain.
This would introducing potential incompatibilities. For example, I remember parsing using these quotes myself (this code isn't used for recent rubies so doing the change wouldn't actually affect it).
Please reject this.
Updated by zverok (Victor Shepelev) over 4 years ago
I fail to see the actual gain.
As it was already pointed in related tickets, the gain (or rather the problem solved) comes when the error message is copy-pasted into any input field supporting Markdown or Markdown-alike syntax. This includes this very tracker; and GitHub/GitLab comments/PRs; and Slack and any of its open- or closed-source modern alternatives, like Gitter or Mattermost; and almost any other of developer-friendly software that emerged in the last 10 years or so. I believe it is relatively small, but constantly annoying problem.
Updated by nobu (Nobuyoshi Nakada) over 4 years ago
zverok (Victor Shepelev) wrote:
I fail to see the actual gain.
As it was already pointed in related tickets, the gain (or rather the problem solved) comes when the error message is copy-pasted into any input field supporting Markdown or Markdown-alike syntax. This includes this very tracker; and GitHub/GitLab comments/PRs; and Slack and any of its open- or closed-source modern alternatives, like Gitter or Mattermost; and almost any other of developer-friendly software that emerged in the last 10 years or so. I believe it is relatively small, but constantly annoying problem.
Why don't you use block quoting?
Updated by zverok (Victor Shepelev) over 4 years ago
Why don't you use block quoting?
Because error messages are by their nature something you frequently want to communicate quickly and inline?
Here are some examples of backtick breaking communication: https://gist.github.com/zverok/a4fcacab3dc06d9d7585c82cad8a8dc6
Updated by vlad0337187 (Vladislav Ivanov) about 4 years ago
Some terminals don't highlight text inside different quotes (for example, Iterm2, Terminal on Mac).
So you're going to double-click, copy; but have to highlight text manually.
Updated by hsbt (Hiroshi SHIBATA) about 4 years ago
- Is duplicate of Bug #17107: Backtick in backtrace is a little bit annoying added
Updated by ioquatix (Samuel Williams) about 2 years ago
The more pervasive Markdown becomes, the more annoying this quoting style becomes.
Updated by nobu (Nobuyoshi Nakada) about 2 years ago
zverok (Victor Shepelev) wrote in #note-12:
Because error messages are by their nature something you frequently want to communicate quickly and inline?
Here are some examples of backtick breaking communication: https://gist.github.com/zverok/a4fcacab3dc06d9d7585c82cad8a8dc6
Why don't you use double- or triple-backticks?
Ugh, do you know why am I having
undefined local variable or method `foo' for main:Object?
.. I expected it to work forLogger
.
Updated by ioquatix (Samuel Williams) about 2 years ago
Why don't you use double- or triple-backticks?
Because that doesn't work for inline Markdown.
Updated by nobu (Nobuyoshi Nakada) about 2 years ago
https://daringfireball.net/projects/markdown/syntax#code
To include a literal backtick character within a code span, you can use multiple backticks as the opening and closing delimiters:
``There is a literal backtick (`) here.``
which will produce this:
<p><code>There is a literal backtick (`) here.</code></p>
Updated by ioquatix (Samuel Williams) about 2 years ago
Not sure if it's well supported, it doesn't work in GitHub issue title which is one place where I have this problem.
Updated by nobu (Nobuyoshi Nakada) about 2 years ago
As it seems working in other than titles, it would be an issue of GitHub.
You should report it to GitHub, not here.
Updated by zverok (Victor Shepelev) about 2 years ago
@nobu (Nobuyoshi Nakada) Even where it works, it is not common knowledge of the way to hack around the necessity to post a singular backtick. Note that it was discovered in the current issue after 2 years of a discussion. (I use markdown almost every day since it was invented, and wrote some toy parsers/transformers for it, and still I didn't know about the two-backticks trick, because of how rarely this need arises)
What the people do every day and everywhere is pasting Ruby exception messages, seeing them converted, becoming frustrated, editing; rinse, repeat. Which is the cause of the current issue.
I wonder what is the necessity to preserve this legacy convention of assimetric `quotes'
?.. Just because it is already this way?.. (If you ask me, it irked me always as also looking weird in the terminal, but maybe it is something personal)(
Updated by sawa (Tsuyoshi Sawada) about 2 years ago
zverok (Victor Shepelev) wrote in #note-21:
(If you ask me, it irked me always as also looking weird in the terminal, but maybe it is something personal)(
Speaking of irking, the weird practice of putting three periods before and after a code block cited in a text, just like how this issue originally was written before my edit https://bugs.ruby-lang.org/journals/83743/diff?detail_id=56117 , is much more irking than using `'
for quotes. The author of this issue should have at least payed attention to use correct punctuation when discussing punctuation. This proposal is very unconvincing.
Updated by austin (Austin Ziegler) about 2 years ago
zverok (Victor Shepelev) wrote in #note-21:
I wonder what is the necessity to preserve this legacy convention of
assimetric `quotes'
?.. Just because it is already this way?.. (If you ask me, it irked me always as also looking weird in the terminal, but maybe it is something personal)
It’s not personal, it‘s based on the fact that the terminal emulators we have been using for a very long time have not supported the exact same fonts as the terminals did, even back in 1989 when I got access. Right now, '
is usually displayed as a vertical quarter bar from the top, but it was displayed on most VT series terminals the same as ’
(raised comma). `
wasn’t shown as a bare grave accent, but was shown as a raised reversed comma, or ‛
.
Like you, I did not know the double backtick trick, even though I’ve been using Markdown since very early (and you need spaces for `
to work, per the Common Mark spec https://spec.commonmark.org/0.30/#code-spans).
Many editors expect GNU-style quoting, so changing the formatting for Ruby would have substantial downstream impact (https://cs.github.com/gcc-mirror/gcc?q=%2F%60%25s%27%2F).
There’s strong opinions (https://english.stackexchange.com/questions/17695/any-reference-on-the-usage-of-a-backtick-and-single-quotation-mark-like-this/) about whether it’s good or bad practice, and I’d love to see it change entirely, but that may be asking a bit much from an entire computer industry.
Updated by zverok (Victor Shepelev) about 2 years ago
the weird practice of putting three periods before and after a code block cited in a text
It is a cultural difference. In many languages/writing conventions, three dots is a sign of "phrase broken in the middle". Can be used when leaving the text unfinished ("I thought it would work, but..."), or to mark a place of insertion of a different content that breaks the text flow, to signify that the phrase continues below: "I've seen photos like... {picture} ...and always thought that it is beautiful".
As a Russian/Ukrainian speaker, I find it natural (note that I am not an original ticket's author, though). In American English, the breaking is more frequently signified with — ("I thought it would work, but—").
That being said, I find your marking it as a "weird practice" and fixing other people's punctuation you find "weird", as well as it being used as a response to my note on my personal perception of exception rendering pretty flabbergasting.
I will stop commenting on this ticket, then.
Updated by ivoanjo (Ivo Anjo) 8 months ago
matz (Yukihiro Matsumoto) wrote in #note-7:
It was something cultural. I admit nowadays very few people use backquote as a left-hand quote, but it used to be. I also admit consistent quotes are easier for our eyes when using recent major fonts. But changing those quotes may affect existing log parsers. We have to estimate how big is the influence of the changes.
Matz.
On the topic of impacting the ecosystem, there have been quite a few changes to how exceptions have been displayed recently:
and even more being discussed https://bugs.ruby-lang.org/issues/19117 .
Overall the impact on the ecosystem seemed quite small, and the gain in usability was nice. So changing the `
to a '
doesn't seem like it would be worse than any of those changes.
Updated by mdalessio (Mike Dalessio) 8 months ago
It may be interesting to note that the Prism parser has adopted a style guide for error messages, which avoids using the mixed quotes, and uses backticks around token literals to render well in markdown.
Updated by joshuap (Josh Wood) 8 months ago
ivoanjo (Ivo Anjo) wrote in #note-25:
matz (Yukihiro Matsumoto) wrote in #note-7:
It was something cultural. I admit nowadays very few people use backquote as a left-hand quote, but it used to be. I also admit consistent quotes are easier for our eyes when using recent major fonts. But changing those quotes may affect existing log parsers. We have to estimate how big is the influence of the changes.
Matz.
On the topic of impacting the ecosystem, there have been quite a few changes to how exceptions have been displayed recently:
and even more being discussed https://bugs.ruby-lang.org/issues/19117 .
Overall the impact on the ecosystem seemed quite small, and the gain in usability was nice. So changing the
`
to a'
doesn't seem like it would be worse than any of those changes.
To chime in here, at Honeybadger we use this regular expression to parse the Ruby backtrace: https://github.com/honeybadger-io/honeybadger-ruby/blob/edc815c136c5d61fb4e8363b2ffafedef246e4fc/lib/honeybadger/backtrace.rb#L10
I don't think it should be too difficult for us to support both the old and new quote formats. As a Ruby user myself, I always found the backtick to be odd, and wasn't aware of the history, which is fascinating.
Updated by matz (Yukihiro Matsumoto) 7 months ago
I agree with giving up backquotes. I'd rather use single quote pairs, unless any compatibility issues are caused.
Matz.
Updated by Dan0042 (Daniel DeLorme) 7 months ago
I'd like something that's convenient to copy-paste. Testing:
with single quote pair:
undefined local variable or method 'foobar' for main:Object (NameError)
undefined local variable or method 'foobar' for main:Object (NameError)
undefined local variable or method 'foobar' for main:Object (NameError)
with backtick pair:
undefined local variable or method foobar
for main:Object (NameError)
undefined local variable or method
foobar for main:Object (NameError)
undefined local variable or method `foobar` for main:Object (NameError)
At first I preferred backticks but given how the above are rendered in markdown I've ended up preferring single quotes.
Updated by Eregon (Benoit Daloze) 7 months ago
Great to see progress on this issue.
Agreed, for method names and file names, single quotes are best.
Backticks are best for quoting source code, and there is no source code in Ruby backtraces.
Updated by mame (Yusuke Endoh) 7 months ago
- Related to Feature #19117: Include the method owner in backtraces, not just the method name added
Updated by mame (Yusuke Endoh) 7 months ago
Let me add a little to the matz's decision.
At the dev meeting, he said that we will replace with a single quote, not only the backticks for NameError#message
, but also the ones for other exception messages (e.g., no superclass method `foo'
) and the ones surrounding the names of methods in the backtrace (e.g., from test.rb:2:in `foo'
).
Matz also wants to experiment with #19117 as well, and I am writing an experimental patch for that. If this is also applied, each line of the backtrace will be
before: from test.rb:9:in `foo'
after : from test.rb:9:in 'Kernel#foo'
We recognize that both this ticket and #19117 are not small incompatibilities, so if they actually change, it would be nice to change them both at once.
Updated by mame (Yusuke Endoh) 7 months ago
I prototyped it: https://github.com/ruby/ruby/pull/9608
Still need to update prism and ruby/spec.
For information in impact assessment: this change made 140 tests fail in make test-all
. Many of them examined error messages, which could be fixed by simply updating the expected regular expression. But there were some non-trivial effects, e.g., irb converts the error message from `top (required)'
to `<main>'
, so this conversion code is also updated.
Updated by matz (Yukihiro Matsumoto) 6 months ago
I am positive. I'd say go. We need to experiment anyway.
Matz.
Updated by mame (Yusuke Endoh) 6 months ago
- Status changed from Open to Closed
Applied in changeset git|25d74b9527cd525042ad0b612b794fa331d3a318.
Do not include a backtick in error messages and backtraces
[Feature #16495]
Updated by ioquatix (Samuel Williams) 6 months ago
For reference, so far I had to make one fix:
It was minor and compatibility with both styles is trivial.