Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to closest Ruby if we can't find an installation for the requested version #2912

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Nov 26, 2024

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.

Copy link
Member Author

vinistock commented Nov 26, 2024

@vinistock vinistock added other Changes that aren't bugfixes, enhancements or breaking changes vscode This pull request should be included in the VS Code extension's release notes labels Nov 26, 2024 — with Graphite App
@vinistock vinistock removed the other Changes that aren't bugfixes, enhancements or breaking changes label Nov 26, 2024
@vinistock vinistock added the enhancement New feature or request label Nov 26, 2024 — with Graphite App
@vinistock vinistock marked this pull request as ready for review November 26, 2024 14:35
@vinistock vinistock requested a review from a team as a code owner November 26, 2024 14:35
@vinistock vinistock force-pushed the 11-22-extract_ruby_fallback_cancellable_flow branch from 96fc38f to db1e70c Compare November 26, 2024 15:48
@vinistock vinistock force-pushed the 11-22-add_fallback_for_missing_rubies branch from be531b5 to b8aff77 Compare November 26, 2024 15:48
@vinistock vinistock changed the base branch from 11-22-extract_ruby_fallback_cancellable_flow to graphite-base/2912 November 26, 2024 16:14
@vinistock vinistock force-pushed the 11-22-add_fallback_for_missing_rubies branch from b8aff77 to e7e02be Compare November 26, 2024 16:14
@vinistock vinistock changed the base branch from graphite-base/2912 to main November 26, 2024 16:15
@vinistock vinistock force-pushed the 11-22-add_fallback_for_missing_rubies branch from e7e02be to 87185b2 Compare November 26, 2024 16:15
vscode/src/ruby/chruby.ts Outdated Show resolved Hide resolved
vscode/src/ruby/chruby.ts Outdated Show resolved Hide resolved
vscode/src/ruby/chruby.ts Outdated Show resolved Hide resolved
vscode/src/ruby/chruby.ts Outdated Show resolved Hide resolved
vscode/src/test/suite/ruby/chruby.test.ts Outdated Show resolved Hide resolved
vscode/src/test/suite/ruby/chruby.test.ts Show resolved Hide resolved
vscode/src/test/suite/ruby/chruby.test.ts Show resolved Hide resolved
@vinistock vinistock force-pushed the 11-22-add_fallback_for_missing_rubies branch from 87185b2 to 933a9b5 Compare November 28, 2024 16:08
@vinistock vinistock requested a review from andyw8 November 28, 2024 16:09
@vinistock vinistock self-assigned this Nov 29, 2024
vscode/src/test/suite/ruby/chruby.test.ts Outdated Show resolved Hide resolved
@vinistock vinistock force-pushed the 11-22-add_fallback_for_missing_rubies branch from 933a9b5 to b76c60b Compare November 29, 2024 15:14
@vinistock vinistock merged commit ff73dc9 into main Nov 29, 2024
36 checks passed
Copy link
Member Author

Merge activity

  • Nov 29, 10:39 AM EST: A user merged this pull request with Graphite.

@vinistock vinistock deleted the 11-22-add_fallback_for_missing_rubies branch November 29, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve chruby handling for missing .ruby-version and missing Ruby installations
2 participants