ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

Ruby-LSP VSCode extension not activating

Open dstoyer opened this issue 2 years ago • 19 comments

Operating System

Ubuntu 22.04.3 LTS

Ruby version

3.2.2

Project has a bundle

  • [ ] Has 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:

  • Install rbenv and ruby as per these instructions found here: https://collectionbuilder.github.io/cb-docs/docs/software/ruby_linux/
    • Verify ruby is installed and recognized at command line: $ ruby -v
  • Follow instructions at https://marketplace.visualstudio.com/items?itemName=Shopify.ruby-lsp
  • Open Ruby file in VS Code.

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

dstoyer avatar Oct 21 '23 20:10 dstoyer

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?

vinistock avatar Oct 24 '23 15:10 vinistock

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?

dstoyer avatar Oct 24 '23 17:10 dstoyer

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"
}

vinistock avatar Oct 24 '23 19:10 vinistock

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 avatar Oct 24 '23 20:10 dstoyer

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.

dstoyer avatar Oct 25 '23 20:10 dstoyer

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?

vinistock avatar Oct 27 '23 15:10 vinistock

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.

dstoyer avatar Nov 07 '23 15:11 dstoyer

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.

vinistock avatar Nov 08 '23 15:11 vinistock

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.

HugoWachalski avatar Dec 11 '23 13:12 HugoWachalski

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

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

andyw8 avatar Dec 11 '23 14:12 andyw8

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

DhrubajitPC avatar Jan 05 '24 08:01 DhrubajitPC

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

github-actions[bot] avatar Mar 05 '24 12:03 github-actions[bot]

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

github-actions[bot] avatar May 19 '24 12:05 github-actions[bot]

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).

vinistock avatar May 29 '24 20:05 vinistock

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

github-actions[bot] avatar Jul 29 '24 12:07 github-actions[bot]

Hello @vinistock cc @TlonUqbar

With regard to your comment in #2376,

There's no requirement that a lockfile be present, but we indeed don't support usage without any workspace folder opened in VS Code https://github.com/Shopify/ruby-lsp/issues/1780.

I have disproofs.

I created a demo repository. https://github.com/kyanny/demo-ruby-lsp-not-activating

Steps to reproduce:

  1. Launch a new Codespace from the repo
  2. Connecting it from local VS Code (or let the browser to open the repo with VS Code)
  3. Open hello.rb
  4. Check Ruby LSP status - it keeps displaying "Starting" (no log outputs from Ruby LSP)

Image

In this way, VS Code opens a workspace, but Ruby LSP doesn't activate.

I also saw a popup message from the extension that clearly indicates "no lockfile was found." I don't see it always - it randomly occurs.

Image

It seems that having Gemfile.lock in the workspace is a requirement. Why don't you add it to https://github.com/Shopify/ruby-lsp/blob/main/TROUBLESHOOTING.md if there's Known Issues section?

kyanny avatar Aug 26 '24 08:08 kyanny

I also saw a popup message from the extension that clearly indicates "no lockfile was found." I don't see it always - it randomly occurs.

When we open on a workspace that has no lockfile, we activate the extension lazily. You have to open a Ruby file for it to activate.

The dialog is there because we had multiple reports of people who hadn't configured their multi-root workspaces and were using the Ruby LSP without access to their dependencies, but the language server is launched regardless.

vinistock avatar Aug 26 '24 13:08 vinistock

Hello! Sorry for the necro, but is there any update on this? I got a system installed recently and testing the solution given in #2376 works for an empty project, but for some reason I still get Couldn't find a workspace for URI: file:///home/... even when I have a Gemfile.lock in the root folder (single root workspace).

f-and avatar Jul 18 '25 22:07 f-and

@f-and can you open a different issue providing more context? This specific issue is about opening VS Code with no folders or workspaces, which we don't currently support. It's not related to the presence of a lockfile or bundle.

vinistock avatar Aug 01 '25 14:08 vinistock