Tuesday 4 July 2023

Install old ruby on MacBook Pro m1/m2 chip using rbenv(Fresh installation)

Installing older ruby prior to 2.7.2 does not work easily on Mac m1/m2 chips. I wasted a lot of time in this.
I will share the steps which worked for me and it might save others time as well.

Make a fresh installation. First uninstall homebrew(brew) and rbenv and remove all the configurations settings that you might have done while trying to install ruby.
You might have homebrew in /opt/homebrew or in some other places like if you enabled rosetta mode.

Make sure to remove all the configurations settings as well in .bash_profile, .zprofile, .zshrc and lets start with a fresh installation.

 Here are the steps that you need to follow:

1) Enable Rosetta mode(This installs all the application using arch -x86_64):

  • Go to Applications => Utilities from finder.

  • Select Terminal.

  • Press CMD+I (capital i) for "Get Info" or right click on go to in

  • Check box for "Open using Rosetta"

  • You will be asked to install Rosetta, install it and restart your Mac.

    2) Install homebrew using this command:


    And follow the instructions in the end to configure homebrew.

    Run cat .zprofile and make sure you have this:

    eval "$(/usr/local/bin/brew shellenv)"


    3) Install rbenv using this command:

    brew install rbenv

    And configure rbenv so that it loads on start.

    Add this to .zshrc:

    eval "$(rbenv init - zsh)"



    4) Finally, Install ruby using this command(Restart your Mac and make sure brew and rbenv commands are working):
    CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.1.7
    These are the steps which worked for me.





    No comments:

    Post a Comment