Mike McQuaid b2b413165f Upgrade vendored Ruby to 2.3.3.
Use this version whenever 2.3.3 isn't installed. Also, remove the Linux
portable Ruby for now until it's built to be the same version.
2017-09-21 14:27:17 +01:00

57 lines
1.6 KiB
Bash

setup-ruby-path() {
local vendor_dir
local vendor_ruby_current_version
local vendor_ruby_path
local ruby_old_version
local minimum_ruby_version="2.3.3"
vendor_dir="$HOMEBREW_LIBRARY/Homebrew/vendor"
vendor_ruby_current_version="$vendor_dir/portable-ruby/current"
vendor_ruby_path="$vendor_ruby_current_version/bin/ruby"
if [[ -z "$HOMEBREW_DEVELOPER" ]]
then
unset HOMEBREW_RUBY_PATH
fi
if [[ -z "$HOMEBREW_RUBY_PATH" && "$HOMEBREW_COMMAND" != "vendor-install" ]]
then
if [[ -x "$vendor_ruby_path" ]]
then
HOMEBREW_RUBY_PATH="$vendor_ruby_path"
if [[ $(readlink "$vendor_ruby_current_version") != "$(<"$vendor_dir/portable-ruby-version")" ]]
then
if ! brew vendor-install ruby --quiet
then
onoe "Failed to upgrade vendor Ruby."
fi
fi
else
if [[ -n "$HOMEBREW_MACOS" ]]
then
HOMEBREW_RUBY_PATH="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
else
HOMEBREW_RUBY_PATH="$(which ruby)"
fi
if [[ -n "$HOMEBREW_RUBY_PATH" ]]
then
ruby_old_version="$("$HOMEBREW_RUBY_PATH" -e "puts Gem::Version.new('$minimum_ruby_version') > Gem::Version.new(RUBY_VERSION)")"
fi
if [[ "$ruby_old_version" == "true" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" ]]
then
brew vendor-install ruby --quiet
if [[ ! -x "$vendor_ruby_path" ]]
then
odie "Failed to install vendor Ruby."
fi
HOMEBREW_RUBY_PATH="$vendor_ruby_path"
fi
fi
fi
export HOMEBREW_RUBY_PATH
}