diff --git a/lib/ruby_lsp/tapioca/addon.rb b/lib/ruby_lsp/tapioca/addon.rb index 6cdaca0c6..49a39b659 100644 --- a/lib/ruby_lsp/tapioca/addon.rb +++ b/lib/ruby_lsp/tapioca/addon.rb @@ -47,7 +47,7 @@ def activate(global_state, outgoing_queue) outgoing_queue << Notification.window_log_message("Activating Tapioca add-on v#{version}") @rails_runner_client.register_server_addon(File.expand_path("server_addon.rb", __dir__)) - check_gemfile_changes + handle_gemfile_changes rescue IncompatibleApiError # The requested version for the Rails add-on no longer matches. We need to upgrade and fix the breaking # changes @@ -114,7 +114,17 @@ def workspace_did_change_watched_files(changes) private sig { void } - def check_gemfile_changes + def handle_gemfile_changes + return unless File.exist?(".git") + + gemfile_status = %x(git status --porcelain Gemfile.lock).strip + return if gemfile_status.empty? + + process_gemfile_changes + end + + sig { returns(T.nilable(Integer)) } + def process_gemfile_changes current_lockfile = File.read("Gemfile.lock") snapshot_lockfile = File.read(GEMFILE_LOCK_SNAPSHOT) if File.exist?(GEMFILE_LOCK_SNAPSHOT)