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

Set BUNDLER_VERSION to avoid version mismatch restarts #2658

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Oct 2, 2024

Motivation

Closes #2532

The reported bug happens on the following conditions:

  1. We require "bundler" to use Bundler APIs to set up the composed bundle
  2. If the required version ends up being different than the one locked in the application's lockfile (under BUNDLED_WITH), then when we run bundle exec ruby-lsp after the composed bundle setup, Bundler will force restart to load the Bundler version specified in the lockfile
  3. When Bundler performs the restart, it erases everything we set as part of the environment, which makes the command fail for users who have settings like BUNDLE_PATH configured

Implementation

The implementation starts to keep track of the locked Bundler version. If there is one, we both set BUNDLER_VERSION in the environment and run all bundle commands with the specified version, which ensures that the composed lockfile under .ruby-lsp will use the same version and avoid restarts.

If the locked Bundler version is not installed, we also auto install it otherwise running bundle _x.x.x_ fails.

Automated Tests

Added a test.

@vinistock vinistock added bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes labels Oct 2, 2024
@vinistock vinistock self-assigned this Oct 2, 2024
@vinistock vinistock requested a review from a team as a code owner October 2, 2024 22:29
@vinistock vinistock requested review from andyw8 and alexcrocha October 2, 2024 22:29
@vinistock vinistock force-pushed the vs-set-bundler-version branch 3 times, most recently from e514449 to 638a35d Compare October 10, 2024 13:44
@vinistock vinistock force-pushed the vs-set-bundler-version branch from 638a35d to 215b9fc Compare October 10, 2024 21:16
@vinistock vinistock merged commit 72f019a into main Oct 11, 2024
34 checks passed
@vinistock vinistock deleted the vs-set-bundler-version branch October 11, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fails to load .ruby-lsp/Gemfile when Bundler version mismatches
2 participants