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

Ruby-LSP fails to start when attempting to use non-standard ruby installation path

Open Ganon11 opened this issue 6 months ago • 1 comments

Description

Ruby-LSP fails to start, as running gem install ruby-lsp uses the wrong version of gem.

As ruby-lsp fails to start, the "collect ruby lsp information" task does not succeed, so this information is manually edited.

Ruby LSP Information

VS Code Version

1.104.1

Ruby LSP Extension Version

0.9.32

Ruby LSP Server Version

0.26.1

Ruby LSP Add-ons

Ruby Version

3.4.1

Ruby Version Manager

custom

Description of problem

I have ruby 3.4.1 built and installed at /home/$company/build/ruby-3.4/, including ruby and gem along with the rest of a typical ruby installation. I am trying to get the extension working with this version of ruby, and not the system-installed version of ruby in /usr/bin/ruby, which is version 2.5.9.

I have the following settings for the extension:

    // ...
    "[ruby]": {
        "editor.defaultColorDecorators": "never",
        "editor.defaultFormatter": "Shopify.ruby-lsp",
        "editor.formatOnSave": true,
        "editor.tabSize": 2,
        "editor.insertSpaces": true,
        "editor.semanticHighlighting.enabled": true,
        "editor.formatOnType": true,
        "editor.wordSeparators": "`~@#$%^&*()-=+[{]}\\|;:'\",.<>/"
    },
    "rubyLsp.rubyVersionManager": {
        "identifier": "custom"
    },
    //"rubyLsp.rubyExecutablePath": "/home/$company/build/ruby-3.4/bin/ruby",
    "rubyLsp.customRubyCommand": "PATH=/home/$company/build/ruby-3.4/bin:$HOME/.gem/ruby/3.4.0/bin:$PATH ruby",
    "rubyLsp.formatter": "none",
    // ...

Activation of the extension seems to work; however, VS Code reports an error when running gem install ruby-lsp. The details of the error:

Failed to setup the bundle: Command failed: gem install ruby-lsp ERROR: Error installing ruby-lsp: There are no versions of rbs (< 5, >= 3) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for? rbs requires Ruby version >= 3.1. The current ruby version is 2.5.0. . See Troubleshooting for help

I think that, by simply running gem install ..., only the system version of gem is being found. I would like /home/$company/build/ruby-3.4/bin/gem to be used, but only /usr/bin/gem is used.

Is there a way to get a customGemCommand, similar to the customRubyCommand, so that my 3.4.1 version of gem can be used properly?

Or is there another way to set this up to work?

Ganon11 avatar Sep 24 '25 18:09 Ganon11