# File lib/bundler.rb, line 229
    def requires_sudo?
      return @requires_sudo if defined?(@checked_for_sudo)

      path = bundle_path
      path = path.parent until path.exist?
      sudo_present = which "sudo"
      bin_dir = Pathname.new(Bundler.system_bindir)
      bin_dir = bin_dir.parent until bin_dir.exist?

      @checked_for_sudo = true
      sudo_gems = !File.writable?(path) || !File.writable?(bin_dir)
      @requires_sudo = settings.allow_sudo? && sudo_gems && sudo_present
    end