diff --git a/lib/ruby_lsp/setup_bundler.rb b/lib/ruby_lsp/setup_bundler.rb index 811dea1774..e520dd1498 100644 --- a/lib/ruby_lsp/setup_bundler.rb +++ b/lib/ruby_lsp/setup_bundler.rb @@ -234,7 +234,7 @@ def run_bundle_install(bundle_gemfile = @gemfile) # If no error occurred, then clear previous errors @error_path.delete if @error_path.exist? $stderr.puts("Ruby LSP> Composed bundle installation complete") - rescue Errno::EPIPE, Bundler::Fetcher::NetworkDownError + rescue Errno::EPIPE, Bundler::HTTPError # There are cases where we expect certain errors to happen occasionally, and we don't want to write them to # a file, which would report to telemetry on the next launch. # diff --git a/test/setup_bundler_test.rb b/test/setup_bundler_test.rb index 94fc0d82dc..ca504d5307 100644 --- a/test/setup_bundler_test.rb +++ b/test/setup_bundler_test.rb @@ -935,6 +935,27 @@ def test_handles_network_down_error_during_bundle_install end end + def test_handles_http_error_during_bundle_install + Dir.mktmpdir do |dir| + Dir.chdir(dir) do + File.write(File.join(dir, "gems.rb"), <<~GEMFILE) + source "https://rubygems.org" + gem "irb" + GEMFILE + + Bundler.with_unbundled_env do + system("bundle install") + + compose = RubyLsp::SetupBundler.new(dir, launcher: true) + compose.expects(:bundle_check).raises(Bundler::HTTPError) + compose.setup! + + refute_path_exists(File.join(dir, ".ruby-lsp", "install_error")) + end + end + end + end + def test_is_resilient_to_pipe_being_closed_by_client_during_compose Dir.mktmpdir do |dir| Dir.chdir(dir) do