Skip to content

Commit

Permalink
Install ruby automatically if rbenv is available
Browse files Browse the repository at this point in the history
People may use other ways to provide the right Ruby version but if they
use rbenv then we can use it automatically.
  • Loading branch information
mkllnk committed Mar 20, 2023
1 parent 02d641a commit fc07d9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions script/rbenv-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
11 changes: 7 additions & 4 deletions script/setup
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ 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"
if command -v rbenv > /dev/null; then
./script/rbenv-install.sh
elif ! ruby --version | grep $RUBY_VERSION > /dev/null; then
RUBY_VERSION=$(cat .ruby-version)

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

Expand Down

0 comments on commit fc07d9f

Please sign in to comment.