diff --git a/Library/Homebrew/dev-cmd/install-bundler-gems.rb b/Library/Homebrew/dev-cmd/install-bundler-gems.rb index efa6ec6d4d422..a4e5956bcebe3 100644 --- a/Library/Homebrew/dev-cmd/install-bundler-gems.rb +++ b/Library/Homebrew/dev-cmd/install-bundler-gems.rb @@ -32,7 +32,6 @@ def run Homebrew.forget_user_gem_groups! end - Process::UID.change_privilege(Process.euid) if Process.euid != Process.uid Homebrew.install_bundler_gems!(groups:) end end diff --git a/Library/Homebrew/utils/gems.rb b/Library/Homebrew/utils/gems.rb index dc60f5b847aee..717a5a006c651 100644 --- a/Library/Homebrew/utils/gems.rb +++ b/Library/Homebrew/utils/gems.rb @@ -300,7 +300,12 @@ def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups: end bundle_installed = if bundle_install_required - if system bundle, "install", out: :err + Process.wait(fork do + # Native build scripts fail if EUID != UID + Process::UID.change_privilege(Process.euid) if Process.euid != Process.uid + exec bundle, "install", out: :err + end) + if $CHILD_STATUS.success? true else message = <<~EOS