-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fallback to closest Ruby if we can't find an installation for the req…
…uested version (#2912) ### Motivation Closes #2793 This PR starts adds a fallback for when the specified Ruby in `.ruby-version` is not found/not installed. The UX is similar to the fallback for missing `.ruby-version` configurations. We show a temporary progress warning the user we're going to fallback and give the chance of cancelling, which allows them to manually configure the right version. ### Implementation The implementation is very similar to the fallback for missing `.ruby-version`. The main distinction is that, when we know the version specified, we can try to fallback to the closest one available. There are a few decisions I baked into the implementation: 1. We do not try to approximate major versions. For example, if the `.ruby-version` file specifies Ruby 4.0.0, we would not try to fallback to 3.0.0. I think this is a fair limitation and since Ruby is so conservative about major versions, it shouldn't be too painful 2. To approximate, we search for the Ruby installation with the smallest difference in minor version using the highest patch version as the tie breaker (this is done with a sort). For example, if the requested version is `3.3.5` and we have `3.1.0` and `3.2.2` installed, we want to pick `3.2.2` because that's closest to `3.3.5`. And as another example, if both `3.2.0` and `3.2.2` are installed, we would pick `3.2.2` because that's the highest patch ### Automated Tests Added tests.
- Loading branch information
Showing
2 changed files
with
169 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters