Source: https://stackoverflow.com/a/78071275
Make Ruby LSP work even old ruby projects.
Outside your main project, create a folder with these two files:
.ruby-version
with a version >=3.0.0
3.0.0
Gemfile
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'ruby-lsp'
gem 'ruby-lsp-rails'
- In your Ruby project, create a VSCode settings file (e.g.
.vscode/settings.json
)
{
"rubyLsp.bundleGemfile": "../path/to/above/Gemfile", // or absolute path
"rubyLsp.rubyVersionManager": "rbenv",
}
- Install Ruby LSP plugin and restart VSCode.