def which(cmd, paths: search_paths)
      if file_with_path?(cmd)
        return cmd if executable_file?(cmd)
        extensions.each do |ext|
          exe = ::File.join(cmd, ext)
          return ::File.absolute_path(exe) if executable_file?(exe)
        end
        return nil
      end

      paths.each do |path|
        if file_with_exec_ext?(cmd)
          exe = ::File.join(path, cmd)
          return ::File.absolute_path(exe) if executable_file?(exe)
        end
        extensions.each do |ext|
          exe = ::File.join(path, "#{cmd}#{ext}")
          return ::File.absolute_path(exe) if executable_file?(exe)
        end
      end
      nil
    end
def which(cmd, paths: search_paths)
      if file_with_path?(cmd)
        return cmd if executable_file?(cmd)
        extensions.each do |ext|
          exe = ::File.join(cmd, ext)
          return ::File.absolute_path(exe) if executable_file?(exe)
        end
        return nil
      end

      paths.each do |path|
        if file_with_exec_ext?(cmd)
          exe = ::File.join(path, cmd)
          return ::File.absolute_path(exe) if executable_file?(exe)
        end
        extensions.each do |ext|
          exe = ::File.join(path, "#{cmd}#{ext}")
          return ::File.absolute_path(exe) if executable_file?(exe)
        end
      end
      nil
    end
Find an executable in a platform independent way

 @param [String] command
   the command to search for
 @param [Array[String]] paths
   the paths to look through

 @example
   which('ruby')                 # => '/usr/local/bin/ruby'
   which('/usr/local/bin/ruby')  # => '/usr/local/bin/ruby'
   which('foo')                  # => nil

 @example
   which('ruby', paths: ['/usr/locale/bin', '/usr/bin', '/bin'])

 @return [String, nil]
   the absolute path to executable if found, `nil` otherwise

 @api public