seattlerb/ruby_parser

Release with 3.2 support

sebfie opened this issue · 2 comments

Hello,

Do you plan to make a release with 3.2 support, I have warning :

NOTE: RubyParser::V32 undefined, using RubyParser::V31.
NOTE: RubyParser::V32 undefined, using RubyParser::V31.
NOTE: RubyParser::V32 undefined, using RubyParser::V31.
NOTE: RubyParser::V32 undefined, using RubyParser::V31.
NOTE: RubyParser::V32 undefined, using RubyParser::V31.
NOTE: RubyParser::V32 undefined, using RubyParser::V31.

Thank you for you work !

For now, you can monkeypatch RubyParser to silence these warnings. We are using HairTrigger in our Rails app, which depends on ruby_parser, so we get these warnings for every db/migration releated rails task. This takes care of it as a temporary workaround in an initializer:

diff --git a/apps/api/config/initializers/00_ruby_parser_patch.rb b/apps/api/config/initializers/00_ruby_parser_patch.rb
new file mode 100644
index 000000000..071d12b14
--- /dev/null
+++ b/apps/api/config/initializers/00_ruby_parser_patch.rb
@@ -0,0 +1,18 @@
+require "ruby_parser"
+
+class RubyParser
+  def self.for_current_ruby
+    name = "V#{RUBY_VERSION[/^\d+\.\d+/].delete "."}"
+    klass = if const_defined? name
+      const_get name
+    else
+      latest = VERSIONS.first
+      # Silence warnings from this for now - can go away once RubyParser gets a proper 3.2 release
+      # See also https://github.com/seattlerb/ruby_parser/issues/334
+      # warn "NOTE: RubyParser::#{name} undefined, using #{latest}."
+      latest
+    end
+
+    klass.new
+  end
+end

Thanks for all the OSS work you've contributed over the years @zenspider !

done