From faa58e65767600608512027d789c046e55761b01 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Wed, 31 May 2023 23:43:24 +0800 Subject: [PATCH] utils/github/api: avoid loading `gh` This is causing errors in third-party taps after Homebrew/homebrew-test-bot#934. Fixes Homebrew/discussions#4546. --- Library/Homebrew/utils/github/api.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/utils/github/api.rb b/Library/Homebrew/utils/github/api.rb index a078e4786a..4759a83560 100644 --- a/Library/Homebrew/utils/github/api.rb +++ b/Library/Homebrew/utils/github/api.rb @@ -126,7 +126,8 @@ module GitHub # Gets the token from the GitHub CLI for github.com. sig { returns(T.nilable(String)) } def self.github_cli_token - env = { "PATH" => PATH.new(Formula["gh"].opt_bin, ENV.fetch("PATH")) } + # Avoid `Formula["gh"].opt_bin` so this method works even with `HOMEBREW_DISABLE_LOAD_FORMULA`. + env = { "PATH" => PATH.new(HOMEBREW_PREFIX/"opt/gh/bin", ENV.fetch("PATH")) } gh_out, _, result = system_command "gh", args: ["auth", "token", "--hostname", "github.com"], env: env,