Install ruby automatically if rbenv is available

People may use other ways to provide the right Ruby version but if they
use rbenv then we can use it automatically.
This commit is contained in:
Maikel Linke
2023-03-17 15:59:31 +11:00
parent 4999e231bc
commit e5e5bf8c17
2 changed files with 10 additions and 4 deletions

View File

@@ -2,6 +2,10 @@
#
# Install our selected Ruby version defined in the .ruby-version file.
#
# Requires:
# - [rbenv](https://github.com/rbenv/rbenv#readme)
# - [ruby-build](https://github.com/rbenv/ruby-build#readme)
#
# If our ruby-build version is outdated and it can't build the version we want
# then we try upgrading ruby-build and installing again.

View File

@@ -17,11 +17,13 @@ YELLOW='\033[0;33m'
RED='\033[0;31m'
NO_COLOR='\033[0m'
RUBY_VERSION=$(cat .ruby-version)
# Check ruby version
if ! ruby --version | grep $RUBY_VERSION > /dev/null; then
printf "${RED}Open Food Network requires ruby ${RUBY_VERSION}${NO_COLOR}. Have a look at: https://github.com/rbenv/rbenv\n"
RUBY_VERSION=$(cat .ruby-version)
if command -v rbenv > /dev/null; then
./script/rbenv-install.sh
elif ! ruby --version | grep $RUBY_VERSION > /dev/null; then
printf "${RED}Open Food Network requires ruby ${RUBY_VERSION}${NO_COLOR}. "
printf "Have a look at: https://github.com/rbenv/rbenv\n"
exit 1
fi