utils/ruby.sh: find usable Ruby from PATH only
This commit is contained in:
parent
b4267d80e4
commit
dcc486fa9e
@ -13,7 +13,7 @@ setup-ruby-path() {
|
|||||||
# When bumping check if HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH (in brew.sh)
|
# When bumping check if HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH (in brew.sh)
|
||||||
# also needs to be changed.
|
# also needs to be changed.
|
||||||
local required_ruby_version="2.6"
|
local required_ruby_version="2.6"
|
||||||
local old_ruby_path ruby_clean_path ruby_user_path
|
local ruby_exec
|
||||||
local advice="
|
local advice="
|
||||||
If there's no Homebrew Portable Ruby available for your processor:
|
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)
|
- install Ruby $required_ruby_version with your system package manager (or rbenv/ruby-build)
|
||||||
@ -25,8 +25,6 @@ If there's no Homebrew Portable Ruby available for your processor:
|
|||||||
vendor_ruby_current_version="$vendor_dir/portable-ruby/current"
|
vendor_ruby_current_version="$vendor_dir/portable-ruby/current"
|
||||||
vendor_ruby_path="$vendor_ruby_current_version/bin/ruby"
|
vendor_ruby_path="$vendor_ruby_current_version/bin/ruby"
|
||||||
|
|
||||||
[[ -n $HOMEBREW_RUBY_PATH ]] && old_ruby_path=$HOMEBREW_RUBY_PATH
|
|
||||||
|
|
||||||
unset HOMEBREW_RUBY_PATH
|
unset HOMEBREW_RUBY_PATH
|
||||||
|
|
||||||
if [[ "$HOMEBREW_COMMAND" != "vendor-install" ]]
|
if [[ "$HOMEBREW_COMMAND" != "vendor-install" ]]
|
||||||
@ -52,17 +50,16 @@ If there's no Homebrew Portable Ruby available for your processor:
|
|||||||
then
|
then
|
||||||
HOMEBREW_RUBY_PATH="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
|
HOMEBREW_RUBY_PATH="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
|
||||||
else
|
else
|
||||||
ruby_clean_path=$(type -P ruby)
|
IFS=$'\n'
|
||||||
ruby_user_path=$(PATH="$HOMEBREW_PATH" type -P ruby)
|
for ruby_exec in $(which -a ruby) $(PATH=$HOMEBREW_PATH which -a ruby)
|
||||||
if [[ $(test-ruby "$old_ruby_path") == "true" ]]; then
|
do
|
||||||
HOMEBREW_RUBY_PATH=$old_ruby_path
|
if [[ $(test-ruby "$ruby_exec") == "true" ]]; then
|
||||||
elif [[ $(test-ruby "$ruby_clean_path") == "true" ]]; then
|
HOMEBREW_RUBY_PATH=$ruby_exec
|
||||||
HOMEBREW_RUBY_PATH=$ruby_clean_path
|
break
|
||||||
elif [[ $(test-ruby "$ruby_user_path") == "true" ]]; then
|
fi
|
||||||
HOMEBREW_RUBY_PATH=$ruby_user_path
|
done
|
||||||
else
|
IFS=$' \t\n'
|
||||||
onoe "Failed to find usable Ruby $required_ruby_version!"
|
[[ -z $HOMEBREW_RUBY_PATH ]] && onoe "Failed to find usable Ruby $required_ruby_version!"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]]
|
if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user