Class: Homebrew::DevCmd::VendorGems Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::VendorGems
- Defined in:
- dev-cmd/vendor-gems.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/vendor_gems.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::VendorGems::Args private
- #run ⇒ void private
- #run_bundle(*args) ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::VendorGems::Args
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/vendor_gems.rbi', line 10 def args; end |
#run ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'dev-cmd/vendor-gems.rb', line 28 def run Homebrew.setup_gem_environment! ENV["PATH"] = (ENV.fetch("PATH").split(":") | ENV.fetch("HOMEBREW_PATH", "").split(":")).join(":") ENV["BUNDLE_WITH"] = Homebrew.valid_gem_groups.join(":") ohai "cd #{HOMEBREW_LIBRARY_PATH}" HOMEBREW_LIBRARY_PATH.cd do if args.update ohai "bundle update" run_bundle "update", *args.update unless args.no_commit? ohai "git add Gemfile.lock" system "git", "add", "Gemfile.lock" end end ohai "bundle install --standalone" run_bundle "install", "--standalone" require "bundler" definition = Bundler::Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, false) # Bundler ships with Ruby, outside the directory hashed by Bootsnap. core_gem_names = definition.specs_for([:default]) .filter_map { |spec| spec.name if spec.name != "bundler" } .sort bootsnap_gem_names = Homebrew::Bootsnap.core_gem_names.sort if core_gem_names != bootsnap_gem_names raise <<~EOS Bootsnap core gem list is out of date. Expected: #{core_gem_names.join(", ")} Actual: #{bootsnap_gem_names.join(", ")} EOS end if GitHub::Actions.env_set? && HOMEBREW_PREFIX.to_s == HOMEBREW_LINUX_DEFAULT_PREFIX ohai "chmod +t -R /home/linuxbrew/" system "sudo", "chmod", "+t", "-R", "/home/linuxbrew/" end ohai "bundle pristine" run_bundle "pristine" ohai "bundle clean" run_bundle "clean" system "git", "add", "Gemfile.lock" unless args.no_commit? if args.non_bundler_gems? %w[ mechanize ].each do |gem| (HOMEBREW_LIBRARY_PATH/"vendor/gems").cd do Pathname.glob("#{gem}-*/").each { |path| FileUtils.rm_r(path) } end ohai "gem install #{gem}" safe_system "gem", "install", gem, "--install-dir", "vendor", "--no-document", "--no-wrappers", "--ignore-dependencies", "--force" (HOMEBREW_LIBRARY_PATH/"vendor/gems").cd do source = Pathname.glob("#{gem}-*/").first next unless source # We cannot use `#ln_sf` here because that has unintended consequences when # the symlink we want to create exists and points to an existing directory. FileUtils.rm_f gem FileUtils.ln_s source, gem end end end unless args.no_commit? ohai "git add vendor" system "git", "add", "vendor" Utils::Git.set_name_email! Utils::Git.setup_gpg! ohai "git commit" system "git", "commit", "--message", "brew vendor-gems: commit updates." end end end |
#run_bundle(*args) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
112 113 114 115 116 117 118 119 120 |
# File 'dev-cmd/vendor-gems.rb', line 112 def run_bundle(*args) Process.wait(fork do # Native build scripts fail if EUID != UID Process::UID.change_privilege(Process.euid) if Process.euid != Process.uid exec "bundle", *args end) raise ErrorDuringExecution.new(["bundle", *args], status: $CHILD_STATUS) unless $CHILD_STATUS.success? end |