Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't change the ruby version I want to run with my Mac (M1)

So I tried to do this tutorial https://programminghistorian.org/en/lessons/building-static-sites-with-jekyll-github-pages#on-a-mac-, but got stuck in the ruby section. Here's what happened and what I have tried:

When trying the tutorial I ran into my first "permission" error trying to use this command line

gem install rubygems-update

So I went ahead to the Jekyll website, read the documentation and figured out that I needed to work around that permission error that my guess is that it is generated becase Macs already have a ruby version that they need to run, and also that even if I install a new ruby version I can't change the one my Mac is running.

I tried everything here on the documentation. Even the rbenv path to install ruby and then when trying to see what version I was running with ruby -v, I got the same thing "2.6.3p62".

Then I found this blog post, and again tried to install it that way and again with homebrew. The only thing I modified from there is:

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile

to this

echo 'export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.1/bin:$PATH"' >> ~/.zshrc

Because after running echo $SHELL it seems my shell is zsh.

However, when I restarted my console and typed ruby -v the terminal displayed the same old version "2.6.3p62". Also I saw here that I can run which ruby after I installed it and run the echo command to see if it is requiring it from the new defined path but no. It's still inside /usr/bin/ruby

I have run out of options and asking for some help. Thank you.

like image 880
Jvet Avatar asked Oct 22 '25 00:10

Jvet


1 Answers

A possible script for the terminal of an M1 chip MacOS to setup a Ruby (any desired version) environment is:

xcode-select --install

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install git

git config --global color.ui true

git config --global user.name "your name here"

git config --global user.email "your_email_here"

Then download VS Code in Chrome and go back to your terminal to enter the following commands.

brew install rbenv

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc

echo 'eval "$(rbenv init -)"' >> ~/.zshrc

source ~/.zshrc

Next up is where you insert your desired version. This time I suggest 2.7.3

rbenv install 2.7.3
    
rbenv global 2.7.3 

rbenv rehash

gem install bundler pry byebug

gem install pry

gem install pry-doc
like image 173
Luis De Avatar answered Oct 23 '25 16:10

Luis De



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!