Improve chruby handling for missing .ruby-version
and missing Ruby installations
#2793
Labels
enhancement
New feature or request
vscode
This pull request should be included in the VS Code extension's release notes
There are some corner cases for our chruby integration that aren't very user friendly at the moment.
Missing .ruby-version file
There are two ways to define a "global" Ruby version with chruby. The first one is to set the version via a shellscript, which doesn't do anything in the editor since the NodeJS process running the extension is not sourcing those files. It only impacts the terminal.
The second one is to define a
.ruby-version
in a parent directory. Chruby goes up directories trying to find a.ruby-version
file. I had assumed that this was quite common and the standard way of using chruby, but based on our telemetry this is clearly not the case.The question then becomes what to do if we can't find a
.ruby-version
in any of the parent directories. We can try to launch with whatever is the latest Ruby installed, but that may conflict with the Ruby constraints defined in theGemfile
, which will fail to launch the language server. We could first check if the Gemfile has that constraint, but that may also mean having to parse the constraints ourselves (e.g.:ruby "~> 3.1"
).We can also try to better explain that adding a
.ruby-version
in parent directories serves as the fallback, but that will still require manual intervention from the user, even if it's just clicking a button to create the new file.Whatever we end up deciding here, it's really important to show in the UI what happened, so that it's clear why the LSP is running with a specific Ruby version.
Missing rubies
The second part of the problem is when there is a
.ruby-version
file, but the version specified is not installed. This is in part related to #2173.We could also try to launch with an alternative Ruby, but we face similar limitations as the ones described previously with Gemfile constraints.
We also don't know how to install rubies for
chruby
since the tool doesn't come with Ruby installation. People can use whatever they want to install Ruby (Homebrew, ruby-install, ruby-build) and then usechruby
only for switching versions, which limits what we can offer as part of the experience here.It might be possible, although a higher maintenance cost, to introduce integration with Ruby installers in addition to version "switchers". That way, for tools like
chruby
that only support switching versions, we can try to discover what the user has available to install rubies and offer to use that.The text was updated successfully, but these errors were encountered: