ruby-lsp: LSP fails to start: Could not find command "_2.5.22_".

This was introduced recently by the following change in #2658 (which resolved #2532):

https://github.com/Shopify/ruby-lsp/blob/72f019a9185da16c349eb57395b65f7a4aab6f2c/lib/ruby_lsp/setup_bundler.rb#L194-L203

Now when trying to activate the LSP in Visual Studio Code I see the following error message: Image

Log excerpts:

Log output
2024-10-17 02:42:10.644 [info] (baw-server) Checking if chruby is available on the path with command: /bin/sh -i -c 'chruby --version'
2024-10-17 02:42:10.650 [info] (baw-server) Checking if rbenv is available on the path with command: /bin/sh -i -c 'rbenv --version'
2024-10-17 02:42:10.655 [info] (baw-server) Checking if rvm is available on the path with command: /bin/sh -i -c 'rvm --version'
2024-10-17 02:42:10.662 [info] (baw-server) Checking if asdf is available on the path with command: /bin/sh -i -c 'asdf --version'
2024-10-17 02:42:10.716 [info] (baw-server) Discovered version manager none
2024-10-17 02:42:10.716 [info] (baw-server) Running command: `ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM:: YJIT), version: RUBY_VERSION }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'` in /home/baw_web/baw-server using shell: /bin/bash
2024-10-17 02:42:11.461 [info] (baw-server) Ruby LSP> Skipping custom bundle setup since LSP dependencies are already in /home/baw_web/baw-server/Gemfile

2024-10-17 02:42:11.559 [info] (baw-server) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle _2.5.22_ check || bundle _2.5.22_ install) 1>&2

2024-10-17 02:42:11.721 [info] (baw-server) Could not find command "_2.5.22_".

2024-10-17 02:42:11.876 [info] (baw-server) Could not find command "_2.5.22_".

2024-10-17 02:42:12.006 [info] (baw-server) Could not find command "_2.5.22_".

2024-10-17 02:42:12.008 [info] (baw-server) [Error - 2:42:12 AM] Server process exited with code 15.
2024-10-17 02:42:12.008 [info] (baw-server) [Error - 2:42:12 AM] Server initialization failed.
2024-10-17 02:42:12.009 [info] (baw-server)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-17 02:42:12.009 [info] (baw-server) [Error - 2:42:12 AM] Ruby LSP client: couldn't create connection to server.
2024-10-17 02:42:12.009 [info] (baw-server)   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-17 02:42:12.009 [error] (baw-server) Error starting the server: Pending response rejected since connection got disposed
2024-10-17 02:42:47.436 [info] (baw-server) [Error - 2:42:47 AM] Connection to server got closed. Server will not be restarted.

I tried:

  • updating bundler
  • installing the lsp gems in my gem file

To avoid running the custom bundle workflow but nothing worked.

I don’t understand how inserting _<version>_ between bundler and the command is meant to form a valid bundler command?


Ruby LSP Information

VS Code Version

1.94.2

Ruby LSP Extension Version

0.8.5

Ruby LSP Server Version

Unknown

Ruby LSP Addons

Ruby Version

3.2.2

Ruby Version Manager

none

Installed Extensions

Click to expand
  • solargraph (0.24.1)
  • gitlens (15.6.1)
  • EditorConfig (0.16.4)
  • copilot (1.239.0)
  • copilot-chat (0.21.2)
  • vscode-pull-request-github (0.98.0)
  • vscode-test-explorer (2.22.1)
  • vscode-rdbg (0.2.2)
  • test-adapter-converter (0.2.0)
  • ruby-lsp (0.8.5)
  • code-spell-checker (3.0.1)

Ruby LSP Settings

Click to expand
Workspace
{}
User
{
  "enableExperimentalFeatures": false,
  "enabledFeatures": {
    "codeActions": true,
    "diagnostics": true,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": true,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": true,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": true,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "auto"
  },
  "customRubyCommand": "",
  "formatter": "auto",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (5 by maintainers)

Commits related to this issue

Most upvoted comments

we could add a check to not concatenate the version string if ./bin is in the PATH and a bin/bundle exists.

The _version_ thing is Rubygems magic, right? Perhaps you could find the path that bundle resolves to (i.e. which bundle), and then see if that path is the binary from an installed gem, or something else (i.e. a bin/bundle binstub). Depending on which one it is, decide whether to add the _version_ arg.

Thank you so much for mentioning the problem with ./bin being in $PATH being the problem here. Once I’ve removed that, everything works fine again with Zed.