LSP doesn't run without YJIT (breaks on non-CRuby)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- ruby, typescript
- Domain
- devtools
Research direction
Start with vscode/src/ruby.ts at the linked YJIT availability check, then reproduce activation using TruffleRuby 24.1.1. Trace the command that adds the --yjit option and verify the LSP can activate on Ruby implementations or builds where YJIT is unavailable, without passing that unsupported flag.
Written by the indexing model from the issue text.
Description
Description
The collection of the Ruby LSP information will not work, presumably because it assumes YJIT is available (e.g., doesn't work with TruffleRuby). I've collected it from another window running with CRuby and tried to manually hack it together:
Ruby LSP Info
### Ruby LSP Information
#### VS Code Version
1.95.3
#### Ruby LSP Extension Version
0.8.14
#### Ruby LSP Server Version
0.22.1
#### Ruby LSP Addons
#### Ruby Version
3.3.5
#### Ruby Version Manager
none
Failed to setup the bundle: Command failed: gem list ruby-lsp language_server-protocol prism rbs sorbet-runtime ERROR: truffleruby: invalid option --yjit (Use --help for usage instructions.) . See Troubleshooting for help
Reproduction steps
- Use TruffleRuby for your project (e.g.,
truffleruby-24.1.1from ruby-build) - Start the Ruby LSP using VS Code
- Open a Ruby file
- See the LSP fail to activate because the
--yjitflag is invalid
Code snippet or error message
The console output suggests that it will only enable YJIT if RubyVM::YJIT is defined:
2024-11-25 11:16:27.635 [info] (nuevo-protobuf) Discovered version manager shadowenv
2024-11-25 11:16:27.641 [info] (nuevo-protobuf) Found shadowenv executable at /opt/homebrew/bin
2024-11-25 11:16:27.642 [info] (nuevo-protobuf) Running command: `/opt/homebrew/bin/shadowenv exec -- ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'` in /Users/nirvdrum/src/github.com/Shopify/nuevo-protobuf using shell: /opt/homebrew/bin/fish
However, I see an error dialog with:
Failed to setup the bundle: Command failed: gem list ruby-lsp language_server-protocol prism rbs sorbet-runtime ERROR: truffleruby: invalid option --yjit (Use --help for usage instructions.) . See [Troubleshooting](https://shopify.github.io/ruby-lsp/troubleshooting.html) for help
Browsing the code, I think the issue is:
TruffleRuby 24.1.1 reports as being Ruby 3.2.4 compatible. While dev builds of TruffleRuby 24.2.0-dev now report as 3.3.5. The check for whether YJIT is available needs to consider more context than just the Ruby version number. I think the check for RubyVM::YJIT is the best approach since it's possible to have a CRuby build without YJIT, so checking for RUBY_ENGINE == "ruby" may be insufficient.
I haven't tried running with JRuby, but I strongly suspect the LSP doesn't run there for similar reasons.
- Dominant language
- Ruby
- Stars
- 2k
- Forks
- 281
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/ruby-lsp
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug help-wanted pinned
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug pinned
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 68/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in Shopify/ruby-lsp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
palladius/rails8-app-on-gcp#145 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
rubocop/rubocop-rspec#2236 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
riscv/riscv-unified-db#2624 · 1 reaction ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100