diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 6288204a6b..a30230f21f 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -10,11 +10,8 @@ module OS @volumes = T.let(get_mounts, T::Array[String]) end - # This is a pre-existing violation that should be refactored - # rubocop:todo Sorbet/AllowIncompatibleOverride - sig { override(allow_incompatible: true).params(path: T.nilable(Pathname)).returns(Integer) } - # rubocop:enable Sorbet/AllowIncompatibleOverride - def which(path) + sig { params(path: T.nilable(Pathname)).returns(Integer) } + def index_of(path) vols = get_mounts path # no volume found @@ -429,13 +426,13 @@ module OS # Find the volumes for the TMP folder & HOMEBREW_CELLAR real_cellar = HOMEBREW_CELLAR.realpath - where_cellar = volumes.which real_cellar + where_cellar = volumes.index_of real_cellar begin tmp = Pathname.new(Dir.mktmpdir("doctor", HOMEBREW_TEMP)) begin real_tmp = tmp.realpath.parent - where_tmp = volumes.which real_tmp + where_tmp = volumes.index_of real_tmp ensure Dir.delete tmp.to_s end diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index c969bfeb8a..0287a54ff7 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -40,7 +40,11 @@ module Homebrew yield if block_given? args.map!(&:to_s) begin - exec(cmd, argv0, *args, **options) + if argv0 + exec(cmd, argv0, *args, **options) + else + exec(cmd, *args, **options) + end rescue nil end