brew/Library/Homebrew/dev-cmd/install-bundler-gems.rb
Mike McQuaid 65f3df92d2
install-bundler-gems: change_privilege when necessary.
This ensures that gems are able to be installed when using e.g.
`ruby -I` in their installation scripts.
2024-04-30 09:21:12 +01:00

41 lines
1.2 KiB
Ruby

# typed: strict
# frozen_string_literal: true
require "abstract_command"
module Homebrew
module DevCmd
class InstallBundlerGems < AbstractCommand
cmd_args do
description <<~EOS
Install Homebrew's Bundler gems.
EOS
comma_array "--groups",
description: "Installs the specified comma-separated list of gem groups (default: last used). " \
"Replaces any previously installed groups."
comma_array "--add-groups",
description: "Installs the specified comma-separated list of gem groups, " \
"in addition to those already installed."
conflicts "--groups", "--add-groups"
named_args :none
end
sig { override.void }
def run
groups = args.groups || args.add_groups || []
if groups.delete("all")
groups |= Homebrew.valid_gem_groups
elsif args.groups # if we have been asked to replace
Homebrew.forget_user_gem_groups!
end
Process::UID.change_privilege(Process.euid) if Process.euid != Process.uid
Homebrew.install_bundler_gems!(groups:)
end
end
end
end