From e5e5bf8c17a206eddf00b3fbbf752555d735697f Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 17 Mar 2023 15:59:31 +1100 Subject: [PATCH] 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. --- script/rbenv-install.sh | 4 ++++ script/setup | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/script/rbenv-install.sh b/script/rbenv-install.sh index 71347a0ef7..e3a2d52fac 100755 --- a/script/rbenv-install.sh +++ b/script/rbenv-install.sh @@ -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. diff --git a/script/setup b/script/setup index 73100989ad..e43f61b7e4 100755 --- a/script/setup +++ b/script/setup @@ -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