Skip to content

Commit 6c21adb

Browse files
authored
Prevent outdated Bundler errors from crashing launcher (#3552)
1 parent 64a03e9 commit 6c21adb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

exe/ruby-lsp-launcher

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ begin
8383
# This Marshal load can only happen after requiring Bundler because it will load a custom error class from Bundler
8484
# itself. If we try to load before requiring, the class will not be defined and loading will fail
8585
error_path = File.join(".ruby-lsp", "install_error")
86-
install_error = if File.exist?(error_path)
87-
Marshal.load(File.read(error_path))
86+
install_error = begin
87+
Marshal.load(File.read(error_path)) if File.exist?(error_path)
88+
rescue ArgumentError
89+
# The class we tried to load is not defined. This might happen when the user upgrades Bundler and new error
90+
# classes are introduced or removed
91+
File.delete(error_path)
92+
nil
8893
end
8994

9095
Bundler.setup

0 commit comments

Comments
 (0)