How to Update Mac Ruby and Gem
How to Update Mac Ruby and Gem
First of all, Home Brew must be installed on your device. If Home Brew is not installed, you can click here and read our article about Home Brew.
If Home Brew is installed on your system, let's proceed to update Ruby and Gem.
Installing the Latest Version of Ruby
First, run the command below in "Terminal" and install the new Ruby version to your device using Home Brew.
brew update brew install ruby gem update --system
After this process is completed, what you need to do is introduce the newly installed Ruby to the system.
Ruby Path Settings
For this, you need to save the following commands to the necessary files using the "nano" editor.
PATH="/usr/local/opt/ruby/bin:$PATH" export LDFLAGS="-L/usr/local/opt/ruby/lib" export CPPFLAGS="-I/usr/local/opt/ruby/include"
You need to add these codes at the bottom of the following files.
- ~/.zshrc
- ~/.zprofile
- ~/.bash_profile
- ~/.bashrc
You can access these files by using "sudo nano filename" as a usage.
For example "sudo nano ~/.bash_profile" — you should do this for the 4 files above.
After adding the above to your file as in the image, you need to run the "source" command so the system registers and recognizes the changes.
For example, "source ~/.zprofile" — you should do this for the 4 files above.
If you've completed all of the above processes smoothly
ruby -v
when you enter the command into the terminal, the latest version should be displayed.
Gem Update Process
Now that we've performed the installation and settings for Ruby, we can make the necessary updates for "gem" with the following command.
sudo gem update --system
If you've completed the above process without any issues and successfully updated gem, then
gem -v
when you enter the command into the terminal, the latest version should be displayed.


Yorum Gönder