Merge pull request #19735 from Homebrew/brew_bundle_exec_env

bundle/commands/exec: adjust environment variable handling (again)
This commit is contained in:
Mike McQuaid 2025-04-10 15:40:44 +00:00 committed by GitHub
commit 8aeaefe629
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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