From 1a1aac97158af7746b711dbb523efb1a052c189b Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 10 Apr 2025 16:16:05 +0100 Subject: [PATCH] bundle/commands/exec: adjust environment variable handling (again) We need to ensure that we keep around some `HOMEBREW_` variables so that the e.g. `git` shim still works in `brew bundle exec`. --- Library/Homebrew/bundle/commands/exec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/bundle/commands/exec.rb b/Library/Homebrew/bundle/commands/exec.rb index b9251cd2a6..b0c00a7a47 100644 --- a/Library/Homebrew/bundle/commands/exec.rb +++ b/Library/Homebrew/bundle/commands/exec.rb @@ -111,16 +111,16 @@ module Homebrew # For commands which aren't either absolute or relative raise "command was not found in your PATH: #{command}" if command.exclude?("/") && which(command).nil? - # Don't need to export Homebrew internal variables that won't be used by other tools. - # Those Homebrew needs have already been set to global constants and/or are exported again later. - # Setting these globally can interfere with nested Homebrew invocations/environments. - ENV.delete_if { |key, _| key.start_with?("HOMEBREW_", "PORTABLE_RUBY_") } - if subcommand == "env" ENV.sort.each do |key, value| # No need to export empty values. next if value.blank? + # Skip exporting Homebrew internal variables that won't be used by other tools. + # Those Homebrew needs have already been set to global constants and/or are exported again later. + # Setting these globally can interfere with nested Homebrew invocations/environments. + next if key.start_with?("HOMEBREW_", "PORTABLE_RUBY_") + # Skip exporting things that were the same in the old environment. old_value = old_env[key] next if old_value == value