Closed pauldruziak closed 2 months ago
@pauldruziak can you check which version of ruby-lsp-rails is active? It should show in the Ruby LSP output panel when it starts up.
@andyw8
2024-07-15 14:07:06.535 [info] (test-app) Initializing Ruby LSP v0.17.7...
and just in case
"clientInfo": {
"name": "Visual Studio Code",
"version": "1.91.1"
},
@pauldruziak I was asking about ruby-lsp-rails
, not ruby-lsp
.
If you don't see it at all, then it may indicate a problem with it detecting that your repo is using Rails.
@andyw8 oh, right. I can't find any lines related to ruby-lsp-rails. And when I run "Ruby LSP: Display addons" it also shows nothing.
@andyw8 I added ruby-lsp-rails
to Gemfile, and now I got:
2024-07-15 16:55:41.886 [info] (test-app) Activating Ruby LSP Rails addon v0.3.10
and code lens start working too
Thanks, you shouldn't need to manually add it though, it is automatically added to the .ruby-lsp/Gemfile
when Rails is detected:
Is there a chance you can try it outside of Docker?
@andyw8 in the test project:
ruby-lsp
and ruby-lsp-rails
gems it stars working as expectedruby-lsp-rspec
it stopped working againIn the working project: I removed all gems, and after that it stopped working. I see the line Activating Ruby LSP Rails addon v0.3.10
, but codeLens
still returns empty results Result: []
@pauldruziak I'm seeing that when ruby-lsp-rspec
is added it does indeed cause the code lenses to no longer appear. Could you please log an issue for that in https://github.com/st0012/ruby-lsp-rspec? (cc @st0012).
I'll close the issue here for now, we can re-open if it turns out changes are needed in Ruby LSP.
^ Ignore the above, @st0012 has identified the cause. We need to make a change in ruby-lsp-rails. I will transfer the issue to that repo, then add further details.
Here's the problem:
Until recently, the only thing that code lenses were used for was on tests. And since ruby-lsp-rails only supports "rails" tests, we return early unless that's the test framework in use:
But now that we're also using code lenses for other purposes, we need to change this, e.g. to split this behaviour into two listeners, initialized separately.
As a quicker fix, we can also just check for the test library inside code lens and then look into splitting listeners.
There is some problem with rspec, but the original problem is unrelated to RSpec.
I removed all ruby-lsp gems from the Gemfile, and I see the next line:
2024-07-16 10:56:16.880 [info] (wealthbox) Finished initializing Ruby LSP!
Activating Ruby LSP Rails addon v0.3.10
Ruby LSP Rails booting server
but it still returns empty results:
2024-07-16 10:57:39.571 [info] (project) [Trace - 10:57:39 AM] Sending request 'textDocument/codeLens - (24)'.
2024-07-16 10:57:39.571 [info] (project) Params: {
"textDocument": {
"uri": "file:///project/app/controllers/users_controller.rb"
}
}
2024-07-16 10:57:39.575 [info] (project) [Trace - 10:57:39 AM] Received response 'textDocument/codeLens - (24)' in 4ms.
2024-07-16 10:57:39.575 [info] (project) Result: []
@pauldruziak try doing a quick edit in the file.
If a code lens request happens before the Rails runtime integration is running, we may end up caching the empty array as the result for that file. If you close and re-open or if you make an edit, you will bust the cache and it should show up.
@vinistock it doens't help 😕
Description
I use vs code inside docker with ruby-lsp. Everything works find except code lens:
I created a new rails app and scaffolded a PostController. So, nothing unusual here: