Module: Utils::PortableRuby Private

Extended by:
Output::Mixin
Defined in:
utils/portable_ruby.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helper functions for the vendored portable-ruby.

Class Method Summary collapse

Methods included from Output::Mixin

issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, pretty_deprecated, pretty_disabled, pretty_duration, pretty_install_status, pretty_installed, pretty_outdated, pretty_uninstalled, pretty_upgradable

Class Method Details

.sync_bundler_version!(pkg_version) ⇒ String

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.

Syncs HOMEBREW_BUNDLER_VERSION in utils/ruby.sh with the bundler shipped by the portable-ruby unpacked at pkg_version.

Parameters:

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'utils/portable_ruby.rb', line 14

def self.sync_bundler_version!(pkg_version)
  unpacked = HOMEBREW_LIBRARY_PATH/"vendor/portable-ruby/#{pkg_version}"
  bundler_dir = Pathname.glob(unpacked/"lib/ruby/gems/*/gems/bundler-*").first
  odie "Cannot find vendored bundler for portable-ruby #{pkg_version}." if bundler_dir.nil?

  bundler_version = bundler_dir.basename.to_s.delete_prefix("bundler-")

  ruby_sh = HOMEBREW_LIBRARY_PATH/"utils/ruby.sh"
  original = ruby_sh.read
  updated = original.sub(/(?<=^export HOMEBREW_BUNDLER_VERSION=")[^"]+/, bundler_version)
  ruby_sh.atomic_write(updated) if original != updated

  bundler_version
end