diff --git a/Library/Homebrew/utils/popen.rb b/Library/Homebrew/utils/popen.rb
index 18cd057fe8c1a1f88ddcd87330d4f2c67c50e570..eac4823c64c90354d4cc57223a3d62437ab80b7d 100644
--- a/Library/Homebrew/utils/popen.rb
+++ b/Library/Homebrew/utils/popen.rb
@@ -1,6 +1,9 @@
 # frozen_string_literal: true
 
 module Utils
+  IO_DEFAULT_BUFFER_SIZE = 4096
+  private_constant :IO_DEFAULT_BUFFER_SIZE
+
   def self.popen_read(*args, **options, &block)
     popen(args, "rb", options, &block)
   end
@@ -18,7 +21,7 @@ module Utils
 
       # Before we yield to the block, capture as much output as we can
       loop do
-        output += pipe.read_nonblock(4096)
+        output += pipe.read_nonblock(IO_DEFAULT_BUFFER_SIZE)
       rescue IO::WaitReadable, EOFError
         break
       end