diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 9c95c0f7fee17aa577b82c068d7b00e276444a47..09a4e7bb285ecfdcb755d980a111c45683ee2edc 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -809,7 +809,7 @@ def check_for_multiple_volumes
   # Find the volumes for the TMP folder & HOMEBREW_CELLAR
   real_cellar = HOMEBREW_CELLAR.realpath
 
-  tmp = Pathname.new with_system_path { `mktemp -d #{HOMEBREW_TEMP}/homebrew-brew-doctor-XXXXXX` }.strip
+  tmp = Pathname.new(Dir.mktmpdir("doctor", HOMEBREW_TEMP))
   real_temp = tmp.realpath.parent
 
   where_cellar = volumes.which real_cellar