@@ -742,6 +742,45 @@ def test_invoke_cli_calls_bundler_directly_for_update
742742 end
743743 end
744744
745+ def test_update_does_not_fail_if_needs_update_path_was_deleted_by_concurrent_process
746+ in_temp_dir do |dir |
747+ File . write ( File . join ( dir , "Gemfile" ) , <<~GEMFILE )
748+ source "https://rubygems.org"
749+ gem "rdoc"
750+ GEMFILE
751+
752+ capture_subprocess_io do
753+ Bundler . with_unbundled_env do
754+ system ( "bundle install" )
755+ run_script ( dir )
756+ end
757+ end
758+
759+ capture_subprocess_io do
760+ Bundler . with_unbundled_env do
761+ needs_update_path = File . join ( dir , ".ruby-lsp" , "needs_update" )
762+
763+ # Simulate a concurrent process deleting the needs_update file during bundle update
764+ mock_update = mock ( "update" )
765+ mock_update . expects ( :run ) . with do
766+ File . delete ( needs_update_path )
767+ true
768+ end
769+ require "bundler/cli/update"
770+ Bundler ::CLI ::Update . expects ( :new ) . with (
771+ { conservative : true } ,
772+ [ "ruby-lsp" , "debug" , "prism" , "rbs" ] ,
773+ ) . returns ( mock_update )
774+
775+ FileUtils . touch ( needs_update_path )
776+ RubyLsp ::SetupBundler . new ( dir , launcher : true ) . setup!
777+
778+ refute_path_exists ( File . join ( dir , ".ruby-lsp" , "install_error" ) )
779+ end
780+ end
781+ end
782+ end
783+
745784 def test_progress_is_printed_to_stderr
746785 in_temp_dir do |dir |
747786 File . write ( File . join ( dir , "Gemfile" ) , <<~GEMFILE )
0 commit comments