Merge pull request #7545 from maxim-belkin/keep_ruby_path_set
utils/ruby.sh: search PATH for Ruby on Linux. update.sh: keep HOMEBREW_RUBY_PATH set.
This commit is contained in:
commit
0b6ae538d1
@ -599,7 +599,6 @@ EOS
|
|||||||
-d "$HOMEBREW_LIBRARY/LinkedKegs" ||
|
-d "$HOMEBREW_LIBRARY/LinkedKegs" ||
|
||||||
(-n "$HOMEBREW_DEVELOPER" && -z "$HOMEBREW_UPDATE_PREINSTALL") ]]
|
(-n "$HOMEBREW_DEVELOPER" && -z "$HOMEBREW_UPDATE_PREINSTALL") ]]
|
||||||
then
|
then
|
||||||
unset HOMEBREW_RUBY_PATH
|
|
||||||
brew update-report "$@"
|
brew update-report "$@"
|
||||||
return $?
|
return $?
|
||||||
elif [[ -z "$HOMEBREW_UPDATE_PREINSTALL" ]]
|
elif [[ -z "$HOMEBREW_UPDATE_PREINSTALL" ]]
|
||||||
|
|||||||
@ -1,28 +1,43 @@
|
|||||||
|
test-ruby () {
|
||||||
|
[[ ! -x $1 ]] && { echo "false"; return 1; }
|
||||||
|
"$1" --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)" 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
setup-ruby-path() {
|
setup-ruby-path() {
|
||||||
local vendor_dir
|
local vendor_dir
|
||||||
local vendor_ruby_current_version
|
|
||||||
local vendor_ruby_path
|
local vendor_ruby_path
|
||||||
|
local vendor_ruby_latest_version
|
||||||
|
local vendor_ruby_current_version
|
||||||
local usable_ruby_version
|
local usable_ruby_version
|
||||||
# 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 ruby_exec
|
||||||
|
local advice="
|
||||||
|
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
|
||||||
|
"
|
||||||
|
|
||||||
vendor_dir="$HOMEBREW_LIBRARY/Homebrew/vendor"
|
vendor_dir="$HOMEBREW_LIBRARY/Homebrew/vendor"
|
||||||
vendor_ruby_current_version="$vendor_dir/portable-ruby/current"
|
vendor_ruby_path="$vendor_dir/portable-ruby/current/bin/ruby"
|
||||||
vendor_ruby_path="$vendor_ruby_current_version/bin/ruby"
|
vendor_ruby_latest_version=$(<"$vendor_dir/portable-ruby-version")
|
||||||
|
vendor_ruby_current_version=$(readlink "$vendor_dir/portable-ruby/current")
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_DEVELOPER" ]]
|
|
||||||
then
|
|
||||||
unset HOMEBREW_RUBY_PATH
|
unset HOMEBREW_RUBY_PATH
|
||||||
|
|
||||||
|
if [[ "$HOMEBREW_COMMAND" == "vendor-install" ]]
|
||||||
|
then
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_RUBY_PATH" && "$HOMEBREW_COMMAND" != "vendor-install" ]]
|
|
||||||
then
|
|
||||||
if [[ -x "$vendor_ruby_path" ]]
|
if [[ -x "$vendor_ruby_path" ]]
|
||||||
then
|
then
|
||||||
HOMEBREW_RUBY_PATH="$vendor_ruby_path"
|
HOMEBREW_RUBY_PATH="$vendor_ruby_path"
|
||||||
|
if [[ $vendor_ruby_current_version != $vendor_ruby_latest_version ]]
|
||||||
if [[ $(readlink "$vendor_ruby_current_version") != "$(<"$vendor_dir/portable-ruby-version")" ]]
|
|
||||||
then
|
then
|
||||||
if ! brew vendor-install ruby
|
if ! brew vendor-install ruby
|
||||||
then
|
then
|
||||||
@ -30,13 +45,7 @@ setup-ruby-path() {
|
|||||||
then
|
then
|
||||||
odie "Failed to upgrade Homebrew Portable Ruby!"
|
odie "Failed to upgrade Homebrew Portable Ruby!"
|
||||||
else
|
else
|
||||||
odie <<-EOS
|
odie "Failed to upgrade Homebrew Portable Ruby!$advice"
|
||||||
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
|
fi
|
||||||
fi
|
fi
|
||||||
@ -45,7 +54,16 @@ EOS
|
|||||||
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
|
||||||
HOMEBREW_RUBY_PATH="$(type -P ruby)"
|
IFS=$'\n' # Do word splitting on new lines only
|
||||||
|
for ruby_exec in $(which -a ruby) $(PATH=$HOMEBREW_PATH which -a ruby)
|
||||||
|
do
|
||||||
|
if [[ $(test-ruby "$ruby_exec") == "true" ]]; then
|
||||||
|
HOMEBREW_RUBY_PATH=$ruby_exec
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS=$' \t\n' # Restore IFS to its default value
|
||||||
|
[[ -z $HOMEBREW_RUBY_PATH ]] && onoe "Failed to find usable Ruby $required_ruby_version!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]]
|
if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]]
|
||||||
@ -53,7 +71,7 @@ EOS
|
|||||||
usable_ruby_version="true"
|
usable_ruby_version="true"
|
||||||
elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]]
|
elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]]
|
||||||
then
|
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)")"
|
usable_ruby_version=$(test-ruby "$HOMEBREW_RUBY_PATH")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || "$usable_ruby_version" != "true" ]]
|
if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || "$usable_ruby_version" != "true" ]]
|
||||||
@ -65,19 +83,12 @@ EOS
|
|||||||
then
|
then
|
||||||
odie "Failed to install Homebrew Portable Ruby (and your system version is too old)!"
|
odie "Failed to install Homebrew Portable Ruby (and your system version is too old)!"
|
||||||
else
|
else
|
||||||
odie <<-EOS
|
odie "Failed to install Homebrew Portable Ruby and cannot find another Ruby $required_ruby_version!$advice"
|
||||||
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
|
||||||
fi
|
fi
|
||||||
HOMEBREW_RUBY_PATH="$vendor_ruby_path"
|
HOMEBREW_RUBY_PATH="$vendor_ruby_path"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
export HOMEBREW_RUBY_PATH
|
export HOMEBREW_RUBY_PATH
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user