1.2.0: linter is disabled on Python 3.11+ ("global flags not at the start of the expression")
SublimeLinter-ruby 1.2.0 (the "Rewrite regex for newer rubys" release) does not load on a Python 3.11+ plugin host: SublimeLinter disables the linter at startup and nothing is ever linted.
Console on Sublime Text 4215 (Windows) right after installing the package from Package Control (the host shows Python 3.14 in other tracebacks):
Package Control: Installed package "SublimeLinter-ruby" 1.2.0
reloading plugin SublimeLinter-ruby.linter
ruby disabled, error compiling regex: global flags not at the start of the expression at position 9 (line 2, column 9).
Cause: the new regex is a triple-quoted string that starts with a newline and indentation before the global flags:
regex = r"""
(?xm)
^(?:(?P<exe>.*:\s)?)? # optional "C:/ruby...:" prefix
Python 3.11 made "global flags not at the start of the expression" an error (it was a DeprecationWarning before), and because x is not in effect yet, the newline and spaces in front of (?xm) count as characters. It is reproducible without Sublime:
>>> import re, sys; sys.version_info[:2]
(3, 12)
>>> re.compile(regex) # regex = the string above
re.error: global flags not at the start of the expression at position 9 (line 2, column 9)
Fix that I checked: start the string with the flags, i.e. regex = r"""(?xm) and keep the rest as is. With only that change, the linter registers and produces results on Ruby 3.4.11 (ruby -wc, Prism format): for
def foo(x)
y = 1
if x = 2
puts "hi"
end
x + 1
z
end
it reports found '= literal' in conditional, should be == (line 3), possibly useless use of + in void context (line 6) and assigned but unused variable - y (line 2), matching ruby -wc; and for def broken(\n puts 1\nend it reports unexpected integer; expected a ) to close the parameters on line 2 at column 7.
The plugin ships .python-version 3.8, so this only bites on Sublime builds where that maps to a newer interpreter, but that is the case for 4215 here. This is separate from #24, which the rewrite fixed for Ruby 3.4.5's output format.