Subject: bug#79257: 31.0.50; flymake's ruby-backend test fails with ruby 3.4.5

From: john muhl <[email-masked]>
Date: Wed, 27 Aug 2025 08:42:23 -0500

Dmitry Gutov <[email-masked]> writes:

> On 27/08/2025 03:24, john muhl wrote:
>> (Oops. My test runners were offline and I mistook their silence
>> for success). I ran the tests on Fedora 42 and they’re still
>> broke. There I find:
>> 
>>    $ which ruby
>>    /usr/sbin/ruby
>> 
>>    $ cat /usr/sbin/ruby
>>    #!/usr/bin/bash
>>    declare -A INTERPRETER_LIST
>>    INTERPRETER_LIST=([_jruby_]=/usr/bin/jruby [_mri_]=/usr/bin/ruby-mri)
>>    ... many more lines
>> 
>> Which as you can see both turns “ruby” into an absolute path and
>> one that doesn’t actually end with “ruby” so the buffer r-f-s sees
>> is like this:
>> 
>>    -:3: warning: statement not reached
>>    /usr/bin/ruby-mri: -:5: syntax errors found (SyntaxError)
>>      3 |   print "not reached"
>>      4 |   something
>>      5 |   oops
>>        |       ^ unexpected end-of-input, assuming it is closing the
>>        | parent top level context
>>      6 |
>>        | ^ expected an `end` to close the `def` statement
>> 
>> I guess the INTERPRETER_LIST thing means there is even some way to
>> turn “ruby” into “/usr/bin/jruby” in the r-f-s buffer.
>
> All right, so Fedora expands the file name (probably substituting a 
> specific interpreter from the "alternatives" system).
>
> Maybe we should try to be clever, relaxing the match but stopping it 
> from going too far, like this:
>
> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
> index 0a6ead870a7..459f8f338f7 100644
> --- a/lisp/progmodes/ruby-mode.el
> +++ b/lisp/progmodes/ruby-mode.el
> @@ -2516,7 +2516,7 @@ ruby-flymake-simple
>        (goto-char (point-min))
>        (cl-loop
>         while (search-forward-regexp
> -             "^\\(?:ruby: \\)?\\(?:.*\\.rb\\|-\\):\\([0-9]+\\): \\(.*\\)$"
> +             "^\\(?:[^:|]+: \\)?\\(?:.*\\.rb\\|-\\):\\([0-9]+\\): 
> \\(.*\\)$"
>                nil t)
>         for msg = (match-string 2)
>         for (beg . end) = (flymake-diag-region

Thanks. That works here for Ruby 3.4.x on Alpine, Fedora and Void.