From 8e4e2d899a432e1d1d120e630879e218e992ad20 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Mon, 2 Mar 2026 21:39:33 +0000 Subject: [PATCH] Apply lower bound `ruby-lsp` version constraint in composed bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the composed `.ruby-lsp/Gemfile` is generated for users who don't have `ruby-lsp` in their own Gemfile, apply a `>= 0.18.0` lower bound. Without this constraint, Bundler could resolve to very old versions that cause errors. Reasons for choosing 0.18.0: - Fixes resolution to versions like 0.11.2 which cause `NameError: uninitialized constant RubyLsp::RuboCop::Cop` - First version with stable Prism 1.0 dependency (`~> 1.0`) — earlier versions used narrow pre-1.0 pins that caused dependency resolution issues - Includes `rbs >= 3` dependency (added in v0.17.3) needed for core class indexing - Not overly restrictive — v0.18.0 is from September 2024, leaving ~18 months of versions available --- lib/ruby_lsp/setup_bundler.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ruby_lsp/setup_bundler.rb b/lib/ruby_lsp/setup_bundler.rb index 846341ab8..a42c3e095 100644 --- a/lib/ruby_lsp/setup_bundler.rb +++ b/lib/ruby_lsp/setup_bundler.rb @@ -34,6 +34,7 @@ def stdout # Gems that should be kept up to date in the composed bundle. When updating, any of these gems that are not # already in the user's Gemfile will be updated together. GEMS_TO_UPDATE = ["ruby-lsp", "debug", "prism", "rbs"].freeze #: Array[String] + RUBY_LSP_MIN_VERSION = "0.18.0" #: String #: (String project_path, **untyped options) -> void def initialize(project_path, **options) @@ -170,9 +171,8 @@ def write_custom_gemfile end unless @dependencies["ruby-lsp"] - ruby_lsp_entry = +'gem "ruby-lsp"' - ruby_lsp_entry << ", \">= 0.a\"" if @beta - ruby_lsp_entry << ", require: false, group: :development" + version = @beta ? "0.a" : RUBY_LSP_MIN_VERSION + ruby_lsp_entry = +"gem \"ruby-lsp\", \">= #{version}\", require: false, group: :development" ruby_lsp_entry << ", github: \"Shopify/ruby-lsp\", branch: \"#{@branch}\"" if @branch parts << ruby_lsp_entry end