mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-15 19:56:59 +08:00

As-of https://github.com/Homebrew/homebrew-portable-ruby/pull/100 we've removed ARM builds for Portable Ruby due to months of breakage. Similarly, when we last bumped Portable Ruby the ARM build was much delayed but, despite Homebrew/brew being completely unusable to anyone using it on ARM in that case, no-one complained or filed issues. Instead of attempting to maintain and update a Portable Ruby on niche (Homebrew) platforms like ARM (or, in past/future PPC) improve the messaging to provide users with a workaround. Now we allow only a major/minor version match it should be pretty doable for those users to install e.g. a prebuilt Ruby binary from a PPA or built it from source if needed using `ruby-build` and `rbenv`. The messaging could be improved further but we're somewhat limited by `ruby.sh` and `vendor-install.sh` being separate. I'm tempted to combine them (or at least have `vendor-install.sh` not be so generic as to not be able to give Ruby-specific advice).
84 lines
2.8 KiB
Bash
84 lines
2.8 KiB
Bash
setup-ruby-path() {
|
|
local vendor_dir
|
|
local vendor_ruby_current_version
|
|
local vendor_ruby_path
|
|
local usable_ruby_version
|
|
# When bumping check if HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH (in brew.sh)
|
|
# also needs to be changed.
|
|
local required_ruby_version="2.6"
|
|
|
|
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
|
|
then
|
|
if [[ -n "$HOMEBREW_MACOS" ]]
|
|
then
|
|
odie "Failed to upgrade Homebrew Portable Ruby!"
|
|
else
|
|
odie <<-EOS
|
|
Failed to upgrade Homebrew Portable Ruby!
|
|
If there's no Homebrew Portable Ruby available for your processor:
|
|
- install Ruby $required_ruby_version with your system package manager (or rbenv/ruby-build)
|
|
- make it first in your PATH
|
|
- try again
|
|
EOS
|
|
fi
|
|
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="$(type -P ruby)"
|
|
fi
|
|
|
|
if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]]
|
|
then
|
|
usable_ruby_version="true"
|
|
elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]]
|
|
then
|
|
usable_ruby_version="$("$HOMEBREW_RUBY_PATH" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -rrubygems -e "puts Gem::Version.new(RUBY_VERSION.to_s.dup).to_s.split('.').first(2) == Gem::Version.new('$required_ruby_version').to_s.split('.').first(2)")"
|
|
fi
|
|
|
|
if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || "$usable_ruby_version" != "true" ]]
|
|
then
|
|
brew vendor-install ruby
|
|
if [[ ! -x "$vendor_ruby_path" ]]
|
|
then
|
|
if [[ -n "$HOMEBREW_MACOS" ]]
|
|
then
|
|
odie "Failed to install Homebrew Portable Ruby (and your system version is too old)!"
|
|
else
|
|
odie <<-EOS
|
|
Failed to install Homebrew Portable Ruby and cannot find another Ruby $required_ruby_version!
|
|
If there's no Homebrew Portable Ruby available for your processor:
|
|
- install $required_ruby_version with your system package manager (or rbenv/ruby-build)
|
|
- make it first in your PATH
|
|
- try again
|
|
EOS
|
|
fi
|
|
fi
|
|
HOMEBREW_RUBY_PATH="$vendor_ruby_path"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
export HOMEBREW_RUBY_PATH
|
|
}
|