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 Jun 18, 2024
1 parent a5a9150 commit 1e7cf51
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 @@ -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

Check warning on line 306 in Library/Homebrew/utils/gems.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/gems.rb#L306

Added line #L306 was not covered by tests
end)
if $CHILD_STATUS.success?

Check warning on line 308 in Library/Homebrew/utils/gems.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/gems.rb#L308

Added line #L308 was not covered by tests
true
else
message = <<~EOS
Expand Down

0 comments on commit 1e7cf51

Please sign in to comment.