From 8d1d0c27c9fb6c4dc0823f71e76d2ebae97c6151 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 12 Dec 2024 17:15:53 +1100 Subject: [PATCH] Install rbenv automatically if missing This small script addition will allow us to remove the rbenv installation from our Ansible provisioning scripts. --- script/rbenv-install.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/script/rbenv-install.sh b/script/rbenv-install.sh index e3a2d52fac..b3b889cd80 100755 --- a/script/rbenv-install.sh +++ b/script/rbenv-install.sh @@ -2,13 +2,24 @@ # # Install our selected Ruby version defined in the .ruby-version file. # -# Requires: +# Requires and tries to install if missing: # - [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. +if ! command -v rbenv > /dev/null; then + # Install rbenv: + git clone https://github.com/rbenv/rbenv.git ~/.rbenv + ~/.rbenv/bin/rbenv init + eval "$(rbenv init -)" + + # Install ruby-build: + mkdir -p "$(rbenv root)"/plugins + git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build +fi + if rbenv install --skip-existing; then echo "Ruby is installed." else