Shopify / ruby-lsp

An opinionated language server for Ruby
https://shopify.github.io/ruby-lsp/
MIT License
1.39k stars 128 forks source link

Ruby-LSP VSCode extension not activating #1780

Open dstoyer opened 8 months ago

dstoyer commented 8 months ago

Operating System

Ubuntu 22.04.3 LTS

Ruby version

3.2.2

Project has a bundle

Ruby version manager being used

rbenv

Description

Ruby-LSP extension for VS Code does not activate. Checking the extension's Runtime Status shows "Not yet activated." There is no text/information in Output when selecting the Ruby-LSP channel. There are no initialization errors, nor any other kind of errors are displayed.

Steps to reproduce:

I also tried restarting VS Code, disabling/enabling Ruby-LSP, uninstalling/reinstalling VS Code.

Ruby Version Manager: rbenv 1.2.0-80-gd6bb1c6

VS Code Info: Version: 1.83.1 Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc Date: 2023-10-10T23:45:31.402Z Electron: 25.8.4 ElectronBuildId: 24154031 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Linux x64 6.2.0-35-generic snap

vinistock commented 8 months ago

Thank you for the report!

I noticed that you mentioned the project you're working on doesn't have a bundle. The extension is activated on two scenarios: if there's a lockfile (bundle) or if you open a Ruby file.

Does opening a Ruby file in the editor not trigger the extension activation for you?

dstoyer commented 8 months ago

Thank you for the report!

I noticed that you mentioned the project you're working on doesn't have a bundle. The extension is activated on two scenarios: if there's a lockfile (bundle) or if you open a Ruby file.

Does opening a Ruby file in the editor not trigger the extension activation for you?

I did open a ruby file in VS Code and it did not trigger the extension activation. I updated the original post to reflect that step to reproduce. Do I need to have a Ruby debugger installed?

vinistock commented 8 months ago

That should not be necessary. It's odd that you're not seeing anything printed in the output and no errors pop up. It feels like activation is not even running for some reason.

Can you try setting the version manager configuration to rbenv?

{
  // This defaults to `auto`, which automatically tries to discover which version manager
  // you are using. Let's see if setting it explicitly fixes it
  "rubyLsp.rubyVersionManager": "rbenv"
}
dstoyer commented 8 months ago

That should not be necessary. It's odd that you're not seeing anything printed in the output and no errors pop up. It feels like activation is not even running for some reason.

I agree, activation seems to not even be running.

Can you try setting the version manager configuration to rbenv? { // This defaults to auto, which automatically tries to discover which version manager // you are using. Let's see if setting it explicitly fixes it "rubyLsp.rubyVersionManager": "rbenv" }


I have set the version manager to "rbenv" with no difference. Still no activation.
dstoyer commented 8 months ago

I ran rdbg --open=vscode <filename>.rb from command line in Terminal and VS Code opened and the Ruby-LSP activated. It only activates if I use that rdbg command. Ruby-LSP does not activate when starting VS Code normally and opening an .rb file.

vinistock commented 8 months ago

Interesting. It may be related to the environment. When you normally open VS Code, do you click on the icon or do you run code . on your terminal? And does running code . on the terminal, activate the LSP properly?

dstoyer commented 8 months ago

Interesting. It may be related to the environment. When you normally open VS Code, do you click on the icon or do you run code . on your terminal? And does running code . on the terminal, activate the LSP properly?

I normally run VS Code from the Activities window (so, icon). When I run code . LSP does activate.

vinistock commented 8 months ago

I'm honestly a bit lost on this one. We register activation events for when there's a lockfile in the current working directory or when the user opens a Ruby file.

I don't know why VS Code would only trigger the extension's activation when opening it through the terminal to be honest.

HugoWachalski commented 6 months ago

Hello, I had the same issue, LSP didn't start anything. I installed VScode throught their website. I didn't have the command line "code ./" in my terminal. So i uninstalled VScode and reinstalled it with brew. Now it works fine.

andyw8 commented 6 months ago

You can enable the code command by following the instructions here:

https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line

DhrubajitPC commented 6 months ago

not sure if this helps, but I had the same experience as @dstoyer

github-actions[bot] commented 4 months ago

This issue is being marked as stale because there was no activity in the last 2 months

github-actions[bot] commented 1 month ago

This issue is being marked as stale because there was no activity in the last 2 months

vinistock commented 1 month ago

I think the issue for this one is that we're currently only activating if there's at least one workspace folder opened in VS Code. If VS Code is opened with a blank window, then we indeed do not activate.

To support that, we'll need to add a "stand alone" mode to the server, launching it without without generating a custom bundle and without bundle exec (which is currently not supported).