Closed Joseph-D-Bradshaw closed 2 months ago
I ran into this problem today and updating bundler (2.5.15
) seems to have fixed it for me.
bundle update --bundler
Perhaps embarrassing, or perhaps a failure of the docs for newcomers, but either way I found out that this Ruby LSP does not work without using bundle
, even if the gemfile itself is empty.
bundle init
and the extension was happy to start analysing the project; perhaps add a Gemfile not found
type error if it is a requirement for the LSP? :) It is sort of hinted when it is confused wondering if it is a multi-workspace project, but knowing it is ultimately because there is no Gemfile would've prevented a newbie like myself to Ruby, from having issues.
Closing as I resolved my particular issue
Can you explain what wasn't working and what the original structure of the project was? If you saw the multi-root workspace warning, then it should have launched the server.
Sure thing, simply 1 ruby file with the mentioned code in it and 1 vscode workspace file (which I added after the LSP didn't come out of starting).
workspace file contents:
{
"folders": [
{
"path": "."
}
],
"settings": {}
}
The .ruby-lsp directory wasn't made. I made some further changes and manually pointed into the ruby.exe on Windows and it made a the .ruby-lsp
but did not come out of the starting state.
The thing that worked was running bundle init
, which I assume just places a Gemfile in the root directory of the project. If only using out of the box functionality - I assume Gemfiles aren't needed in Ruby (for learnings sake); if I'm wrong then the LSP extension is behaving correctly. But if not, I would consider trying to make an empty Ruby project without Gemfile on a new system and seeing if you get the same issues.
I replicated it on Windows and Mac, and tried again on the Mac without bundle init to confirm.
The .ruby-lsp directory wasn't made. I made some further changes and manually pointed into the ruby.exe on Windows and it made a the .ruby-lsp but did not come out of the starting state.
When you have workspace configurations and no lockfile, we don't try to eagerly boot the language server. If you open a Ruby file inside that workspace, then it should lazily launch. I suspect this was the reason, because it is possible to use the Ruby LSP without a bundle.
I have https://github.com/Shopify/ruby-lsp/pull/2283 up for eagerly launching the server if the editor is already focused on a Ruby document, which should likely improve this too.
The .ruby-lsp directory wasn't made. I made some further changes and manually pointed into the ruby.exe on Windows and it made a the .ruby-lsp but did not come out of the starting state.
When you have workspace configurations and no lockfile, we don't try to eagerly boot the language server. If you open a Ruby file inside that workspace, then it should lazily launch. I suspect this was the reason, because it is possible to use the Ruby LSP without a bundle.
I have #2283 up for eagerly launching the server if the editor is already focused on a Ruby document, which should likely improve this too.
I'm fairly confident I made new Ruby files and clicked between them whilst testing, which didn't get the LSP server to start. But I will try again when https://github.com/Shopify/ruby-lsp/pull/2283 is merged. I assume if this is on master then by extension it is in the VSCode extension marketplace?
Description
Windows 11/MacOS Sonoma 14.5
Windows: ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x64-mingw-ucrt] (via RubyInstaller)
MacOS: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23] (via rbenv)
Ruby LSP stuck in
Ruby LSP: Starting
. Output tab in VSCode is blank.Trying to follow an online Learn Ruby the Hard Way.
Reproduction steps
my_project
ex1.rb
class Test def initialize
end end
Test.new