Skip to content

Commit f07643b

Browse files
committed
Fix incompatible addon version activation when Bundler.setup fails after retry
When Bundler.setup raises GemNotFound or GitError and the retry has already been attempted (or install_error is set), the rescue block fell through without setting setup_error. This caused the server to boot thinking setup succeeded, bypassing the load_addons guard. Without Bundler constraining Gem.find_files, every installed version of every addon gem was discovered, leading to version mismatches (e.g., ruby-lsp-rails 0.4.2 loaded with ruby-lsp 0.26.5) and ArgumentError crashes. The StandardError rescue already handled this correctly - this aligns the GemNotFound/GitError rescue to do the same.
1 parent b1074ef commit f07643b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

exe/ruby-lsp-launcher

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ begin
101101
Bundler.setup
102102
$stderr.puts("Composed Bundle set up successfully")
103103
end
104-
rescue Bundler::GemNotFound, Bundler::GitError
104+
rescue Bundler::GemNotFound, Bundler::GitError => e
105105
# Sometimes, we successfully set up the bundle, but users either change their Gemfile or uninstall gems from an
106106
# external process. If there's no install error, but the gem is still not found, then we need to attempt to start from
107107
# scratch
@@ -113,6 +113,10 @@ rescue Bundler::GemNotFound, Bundler::GitError
113113
exec(Gem.ruby, __FILE__, *ARGV, "--retry")
114114
end
115115
end
116+
117+
setup_error = e
118+
$stderr.puts("Failed to set up composed Bundle\n#{e.full_message}")
119+
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
116120
rescue StandardError => e
117121
setup_error = e
118122
$stderr.puts("Failed to set up composed Bundle\n#{e.full_message}")

0 commit comments

Comments
 (0)