Skip to content

Commit 8e4e2d8

Browse files
committed
Apply lower bound ruby-lsp version constraint in composed bundle
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
1 parent a6dcd96 commit 8e4e2d8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/ruby_lsp/setup_bundler.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def stdout
3434
# Gems that should be kept up to date in the composed bundle. When updating, any of these gems that are not
3535
# already in the user's Gemfile will be updated together.
3636
GEMS_TO_UPDATE = ["ruby-lsp", "debug", "prism", "rbs"].freeze #: Array[String]
37+
RUBY_LSP_MIN_VERSION = "0.18.0" #: String
3738

3839
#: (String project_path, **untyped options) -> void
3940
def initialize(project_path, **options)
@@ -170,9 +171,8 @@ def write_custom_gemfile
170171
end
171172

172173
unless @dependencies["ruby-lsp"]
173-
ruby_lsp_entry = +'gem "ruby-lsp"'
174-
ruby_lsp_entry << ", \">= 0.a\"" if @beta
175-
ruby_lsp_entry << ", require: false, group: :development"
174+
version = @beta ? "0.a" : RUBY_LSP_MIN_VERSION
175+
ruby_lsp_entry = +"gem \"ruby-lsp\", \">= #{version}\", require: false, group: :development"
176176
ruby_lsp_entry << ", github: \"Shopify/ruby-lsp\", branch: \"#{@branch}\"" if @branch
177177
parts << ruby_lsp_entry
178178
end

0 commit comments

Comments
 (0)