diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index 8b18071d5f0ee..4eb6aab222932 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -122,7 +122,7 @@ def install } with_env(new_env) do - if args.debug? + if args.debug? && !Homebrew::EnvConfig.disable_debrew? require "debrew" formula.extend(Debrew::Formula) end diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index 35b56c45eec87..68cdcef9abc86 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -152,6 +152,10 @@ module EnvConfig "budding) by e.g. turning warnings into errors.", boolean: true, }, + HOMEBREW_DISABLE_DEBREW: { + description: "If set, the interactive formula debugger available via `--debug` will be disabled.", + boolean: true, + }, HOMEBREW_DISABLE_LOAD_FORMULA: { description: "If set, refuse to load formulae. This is useful when formulae are not trusted (such " \ "as in pull requests).", diff --git a/Library/Homebrew/postinstall.rb b/Library/Homebrew/postinstall.rb index a00f344f0845d..5a4eefc2e30d3 100644 --- a/Library/Homebrew/postinstall.rb +++ b/Library/Homebrew/postinstall.rb @@ -21,7 +21,7 @@ trap("INT", old_trap) formula = T.must(args.named.to_resolved_formulae.first) - if args.debug? + if args.debug? && !Homebrew::EnvConfig.disable_debrew? require "debrew" formula.extend(Debrew::Formula) end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi index 2d527e640be92..6248e99c6c861 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi @@ -88,6 +88,9 @@ module Homebrew::EnvConfig sig { returns(T::Boolean) } def developer?; end + sig { returns(T::Boolean) } + def disable_debrew?; end + sig { returns(T::Boolean) } def disable_load_formula?; end diff --git a/Library/Homebrew/test.rb b/Library/Homebrew/test.rb index 7a13b716941fa..5576563e1700c 100644 --- a/Library/Homebrew/test.rb +++ b/Library/Homebrew/test.rb @@ -35,7 +35,7 @@ formula = T.must(args.named.to_resolved_formulae.first) formula.extend(Homebrew::Assertions) formula.extend(Homebrew::FreePort) - if args.debug? + if args.debug? && !Homebrew::EnvConfig.disable_debrew? require "debrew" formula.extend(Debrew::Formula) end diff --git a/docs/Manpage.md b/docs/Manpage.md index 1131883df5813..e3b493353976c 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -3691,6 +3691,11 @@ command execution e.g. `$(cat file)`. : If set, tweak behaviour to be more relevant for Homebrew developers (active or budding) by e.g. turning warnings into errors. +`HOMEBREW_DISABLE_DEBREW` + +: If set, the interactive formula debugger available via `--debug` will be + disabled. + `HOMEBREW_DISABLE_LOAD_FORMULA` : If set, refuse to load formulae. This is useful when formulae are not trusted diff --git a/manpages/brew.1 b/manpages/brew.1 index 718567b7340cf..7231155458e20 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -2395,6 +2395,9 @@ If set, always assume \fB\-\-debug\fP when running commands\. \fBHOMEBREW_DEVELOPER\fP If set, tweak behaviour to be more relevant for Homebrew developers (active or budding) by e\.g\. turning warnings into errors\. .TP +\fBHOMEBREW_DISABLE_DEBREW\fP +If set, the interactive formula debugger available via \fB\-\-debug\fP will be disabled\. +.TP \fBHOMEBREW_DISABLE_LOAD_FORMULA\fP If set, refuse to load formulae\. This is useful when formulae are not trusted (such as in pull requests)\. .TP