From e28fe444a5fd1fdac2123996ade667744d461da6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 2 Sep 2025 17:00:34 +0100 Subject: [PATCH] Make `Pathname.prepend WriteMkpathExtension` as late as possible. Let's avoid weirdness in other parts of Homebrew by moving this prepend to be as late as possible. --- Library/Homebrew/build.rb | 4 ++-- Library/Homebrew/postinstall.rb | 2 +- Library/Homebrew/test.rb | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index 75e9305b61..adebc41e33 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -183,6 +183,8 @@ class Build (formula.logs/"00.options.out").write \ "#{formula.full_name} #{formula.build.used_options.sort.join(" ")}".strip + + Pathname.prepend WriteMkpathExtension formula.install stdlibs = detect_stdlibs @@ -247,8 +249,6 @@ begin options = Options.create(args.flags_only) build = Build.new(formula, options, args:) - Pathname.prepend WriteMkpathExtension - build.install # Any exception means the build did not complete. # The `case` for what to do per-exception class is further down. diff --git a/Library/Homebrew/postinstall.rb b/Library/Homebrew/postinstall.rb index bc89cce9f4..eb5151c3b1 100644 --- a/Library/Homebrew/postinstall.rb +++ b/Library/Homebrew/postinstall.rb @@ -32,8 +32,8 @@ begin end Pathname.prepend WriteMkpathExtension - formula.run_post_install + # Handle all possible exceptions. rescue Exception => e # rubocop:disable Lint/RescueException error_pipe&.puts e.to_json diff --git a/Library/Homebrew/test.rb b/Library/Homebrew/test.rb index 1146a0dd99..ea935d820c 100644 --- a/Library/Homebrew/test.rb +++ b/Library/Homebrew/test.rb @@ -45,10 +45,9 @@ begin formula.extend(Debrew::Formula) end - Pathname.prepend WriteMkpathExtension - ENV.extend(Stdenv) ENV.setup_build_environment(formula:, testing_formula: true) + Pathname.prepend WriteMkpathExtension # tests can also return false to indicate failure run_test = proc { |_ = nil| raise "test returned false" if formula.run_test(keep_tmp: args.keep_tmp?) == false }