Shopify / ruby-lsp-rails

A Ruby LSP addon for Rails
https://shopify.github.io/ruby-lsp-rails/
MIT License
512 stars 21 forks source link

Error on `ActiveRecord::Base` comparison with RLR 0.3.7 with Rails 6.1 #404

Closed D-system closed 18 hours ago

D-system commented 2 days ago

Using ruby_lsp_rails 0.3.7 and ruby_lsp 0.16.7 with Rails 6.1.7.8, I got the following error:

2024-06-28 18:24:28.145 [info] (ec_3) Ruby LSP Rails error: /Users/thomas/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.7/lib/ruby_lsp/ruby_lsp_rails/server.rb:146:in `>': compared with non class/module (TypeError)

            ActiveRecord::Base > const && # We do this 'backwards' in case the class overwrites `<`
                                 ^^^^^
    from /Users/thomas/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.7/lib/ruby_lsp/ruby_lsp_rails/server.rb:146:in `active_record_model?'
    from /Users/thomas/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.7/lib/ruby_lsp/ruby_lsp_rails/server.rb:96:in `resolve_database_info_from_model'
    from /Users/thomas/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.7/lib/ruby_lsp/ruby_lsp_rails/server.rb:49:in `execute'
    from /Users/thomas/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.7/lib/ruby_lsp/ruby_lsp_rails/server.rb:35:in `start'
    from /Users/thomas/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.7/lib/ruby_lsp/ruby_lsp_rails/server.rb:154:in `<top (required)>'
    from /Users/thomas/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/railties-6.1.7.8/lib/rails/commands/runner/runner_command.rb:42:in `load'
[...]

The error point to those lines: https://github.com/Shopify/ruby-lsp-rails/blob/5704d93c5b70a995160b3fd8a6cfb8c971bc2fed/lib/ruby_lsp/ruby_lsp_rails/server.rb#L142-L150

Which has been change 2 weeks ago by https://github.com/Shopify/ruby-lsp-rails/commit/9be01d0c201dbdb9b6c743a271527365f8543089

The 0.3.6 does not have that error.

Earlopain commented 2 days ago

The commit which fixes this (the one you linked) isn't part of a release yet.

andyw8 commented 18 hours ago

We have just released v0.3.8 which contains this fix.