Open In App

How to Install RubyGems on MacOS?

Ruby is a high-level and open-source programming language. It is very useful in many aspects. Like other programming languages, Ruby is nowadays a highly useful programming language. In Ruby, there is a package manager available which is known as Gems. It is easily distributed and provides libraries to different Ruby programs. For installing Gems, RubyGems is used. Nowadays, RubyGems can be installed along with Ruby. There is no other way to install RubyGems apart from Ruby. RubyGems can also define as the hosting services in Ruby. It helps to run the Gems which are going to publish and install on the machine. Gem is generally a software package. It is used to modify the functions of Ruby applications.

Features:



Installation of RubyGems on MacOS

For installing Ruby in Mac, at first most important prerequisite is in the machine there should be homebrew installed previously. Otherwise, it will give an error.

Step 1: The following command should be run in the terminal. It will start downloading and initialize installing Ruby in Mac.



brew install ruby

 

Step 2: After installing Ruby on Mac. The path environment should be set in the Mac. Otherwise, it will not run.

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

 

Step 3: Then the following command should be run. It will generate all path environments in the Mac machine.

Cat Users/.bash_profile

 

Step 4: After running the above command the below output will be there. There the path for Ruby will also be displayed.

 

Step 5: At last, the following command should be run. It will display the proper version of Ruby installation. With proper installation of Ruby, RubyGems is also installed. Hence installation is successful.

ruby -v

 

Install New Gems

For installing a new Gem, the following command should be run. This simple command will create a new Gem in the system.

bundle gem <gemname>

 

Update RubyGems

For updating RubyGems the following command should be run.  It will take some time. Then it will update to the certain version of Gems if it is needed according to the machine configuration.

gem update –system

 

 

List Installed Gems

For listing up the Gems, which have been installed previously the following command should be run. This will list down the Gems name, as shown in the picture below.

gem list

 

Article Tags :