Skip to content

Conversation

@bniladridas
Copy link
Owner

@bniladridas bniladridas commented Dec 11, 2025

Summary

  • Added interactive prompt in setup-mac.sh to choose between direct Homebrew Ruby install or rbenv for version management.
  • Improved rbenv workflow: installs rbenv, initializes it for current session, installs Ruby 3.2.2, and sets as global.
  • Added proper error handling and logging for both installation methods.
  • Refactored code to use case statement for better maintainability.

@harperbot
Copy link

harperbot bot commented Dec 11, 2025

HarperBot

HarperBot Analysis

Error generating analysis: API quota exceeded (PR: feat: Add rbenv option for Ruby installation, Model: gemini-2.0-flash, Diff length: 681). Please check your billing or try again later.


@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bniladridas, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the setup-mac.sh script by introducing flexibility in Ruby installation. Instead of a single direct Homebrew installation, users can now opt for rbenv to manage Ruby versions, providing a more robust and customizable development environment setup for macOS users.

Highlights

  • Ruby Installation Choice: The setup-mac.sh script now presents an interactive prompt, allowing users to choose between a direct Homebrew Ruby installation or using rbenv for Ruby version management.
  • rbenv Integration: If rbenv is selected, the script will install rbenv via Homebrew, configure ~/.zshrc for rbenv initialization, adjust the PATH, and set Ruby version 3.2.2 as the global default.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a useful feature to allow choosing between a direct Homebrew Ruby installation and using rbenv for version management. The implementation has a few critical issues in the rbenv installation logic that will cause the script to fail. Specifically, it misses the Ruby installation step via rbenv install and doesn't initialize rbenv for the current script session. I've provided a detailed comment with a code suggestion that fixes these issues, improves the code structure by using a case statement to avoid duplication, and adds error handling for consistency with the rest of the script.

setup-mac.sh Outdated
Comment on lines 98 to 110
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The rbenv installation logic has a few critical issues and can be improved for clarity and robustness.

  1. Broken rbenv workflow: The current logic will fail because:

    • It tries to set a global Ruby version (rbenv global 3.2.2) without first installing it via rbenv install 3.2.2.
    • rbenv commands won't work correctly in the current script session because rbenv is not initialized. The echo ... >> ~/.zshrc only configures future shell sessions. You need to run eval "$(rbenv init -)" within the script.
    • The export PATH on line 105 is not the correct way to configure the path for rbenv; this is handled by rbenv init.
  2. Code Structure: The if/elif/else block duplicates the brew install ruby command. Using a case statement is a cleaner way to handle multiple choices and improves maintainability.

  3. Missing Error Handling: For consistency with other installation steps in this script (like Python and Node.js), it's good practice to add explicit error handling for the installation commands.

Here is a suggested replacement that addresses these points:

read -r -p "Choose Ruby installation method (1 for direct brew install, 2 for rbenv): " ruby_choice
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

@harperbot
Copy link

harperbot bot commented Dec 11, 2025

HarperBot

HarperBot Analysis

Error generating analysis: API quota exceeded (PR: feat: Add rbenv option for Ruby installation, Model: gemini-2.0-flash, Diff length: 1294). Please check your billing or try again later.


@bniladridas bniladridas merged commit 0cf65d2 into main Dec 11, 2025
9 checks passed
@bniladridas bniladridas deleted the feature/rbenv-support branch December 11, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants