From eec660de4126702b898afab00fcd5e6a1377076f Mon Sep 17 00:00:00 2001 From: Niladri Das Date: Fri, 12 Dec 2025 03:30:10 +0530 Subject: [PATCH 1/3] feat: add rbenv option for ruby install --- setup-mac.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/setup-mac.sh b/setup-mac.sh index fe6c3dd..c4865e2 100755 --- a/setup-mac.sh +++ b/setup-mac.sh @@ -95,7 +95,18 @@ else fi echo "Installing Ruby..." -brew install ruby +read -r -p "Choose Ruby installation method (1 for direct brew install, 2 for rbenv): " ruby_choice +if [ "$ruby_choice" = "1" ]; then + brew install ruby +elif [ "$ruby_choice" = "2" ]; then + brew install rbenv + echo 'eval "$(rbenv init -)"' >> ~/.zshrc + export PATH="/opt/homebrew/bin:$PATH" + rbenv global 3.2.2 +else + echo "Invalid choice, installing Ruby directly." + brew install ruby +fi echo "Installing Cocoapods..." brew install cocoapods From 024d9f5858c87f267def23ed7ff9989649c9fc7b Mon Sep 17 00:00:00 2001 From: Niladri Das Date: Fri, 12 Dec 2025 03:31:04 +0530 Subject: [PATCH 2/3] fix: suppress shellcheck warning for rbenv init --- setup-mac.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup-mac.sh b/setup-mac.sh index c4865e2..02eec77 100755 --- a/setup-mac.sh +++ b/setup-mac.sh @@ -100,6 +100,7 @@ if [ "$ruby_choice" = "1" ]; then brew install ruby elif [ "$ruby_choice" = "2" ]; then brew install rbenv + # shellcheck disable=SC2016 echo 'eval "$(rbenv init -)"' >> ~/.zshrc export PATH="/opt/homebrew/bin:$PATH" rbenv global 3.2.2 From 3522918ce85926be13ed2f94a66208f1848a7c00 Mon Sep 17 00:00:00 2001 From: Niladri Das Date: Fri, 12 Dec 2025 03:34:10 +0530 Subject: [PATCH 3/3] refactor: improve rbenv logic --- setup-mac.sh | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/setup-mac.sh b/setup-mac.sh index 02eec77..6639816 100755 --- a/setup-mac.sh +++ b/setup-mac.sh @@ -96,18 +96,40 @@ fi echo "Installing Ruby..." read -r -p "Choose Ruby installation method (1 for direct brew install, 2 for rbenv): " ruby_choice -if [ "$ruby_choice" = "1" ]; then - brew install ruby -elif [ "$ruby_choice" = "2" ]; then - brew install rbenv - # shellcheck disable=SC2016 - echo 'eval "$(rbenv init -)"' >> ~/.zshrc - export PATH="/opt/homebrew/bin:$PATH" - rbenv global 3.2.2 -else - echo "Invalid choice, installing Ruby directly." - brew install ruby -fi +case "$ruby_choice" in + 2) + log "Installing rbenv..." + if ! brew install rbenv; then + log "ERROR: Failed to install rbenv." + exit 1 + fi + # Add rbenv to zsh for future sessions + # shellcheck disable=SC2016 + echo 'eval "$(rbenv init -)"' >> ~/.zshrc + # Initialize rbenv for the current script session + eval "$(rbenv init -)" + + log "Installing Ruby 3.2.2 with rbenv (this may take a while)..." + if rbenv install 3.2.2; then + rbenv global 3.2.2 + log "Ruby 3.2.2 installed and set as global via rbenv." + else + log "ERROR: Failed to install Ruby 3.2.2 with rbenv." + exit 1 + fi + ;; + *) + if [ "$ruby_choice" != "1" ]; then + echo "Invalid choice, installing Ruby directly." + fi + if brew install ruby; then + log "Ruby installed directly via Homebrew." + else + log "ERROR: Failed to install Ruby." + exit 1 + fi + ;; +esac echo "Installing Cocoapods..." brew install cocoapods