Skip to content

Commit

Permalink
utils/gems: handle mismatching EUID and UID for bundle installs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed May 1, 2024
1 parent e479f4b commit 1d6784f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion Library/Homebrew/dev-cmd/install-bundler-gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion Library/Homebrew/utils/gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,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
Expand Down

0 comments on commit 1d6784f

Please sign in to comment.