Open In App

How to Install a local gem in Ruby?

Last Updated : 31 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Ruby is a high-level and open-source programming language. It is very useful in many aspects. For programming productivity and simplicity, the Ruby language is widely used. Like Java, Python, Ruby is nowadays a highly useful programming language. In Ruby, there is a package manager called Gems. It is usually easily distributed and provides libraries to different Ruby programs. For installing Gems, RubyGems is used. Usually, Gems are installed while connected to the internet. But also, Gems can be installed Offline also. The Gems, which are created in offline mode, are called local Gems. Usually, one creates local Gems when they don’t have an internet connection or then are using some sensitive documents that they won’t want to share over the internet.

Features:

  • Ruby is widely used for its speed & interactive user interface.
  • In Ruby, every small part of code can have its own properties.
  • Ruby is highly flexible a programming language.

Installing Local Gems

To install a local gem in ruby follow the following step:

Step 1: At first, the following command should be run in the terminal. This command will create a Gemset in Ruby. Gemset is the initial point while creating the Gems. If ruby is not installed in your system then first install Ruby in your system and then run this command.

rvm gemset create demo

Create-a-Gemset-in-Ruby

 

Step 2: After creating Gemset, it will be used to move forward. The following command will be run. This will use the created Gemset.

rvm gemset use demo

 Use-the-created-Gemset

 

Step 3: Then the following command should be used. By this command, the user gives an indication to RubyGems that they are going to create a Local Gems with a certain name. By using that name, many other operations can be done.

gem list <gem-name>

Creating-local-gems

 

Step 4: Then using the Local Gems name, it will be installed in the machine. The following command is used to install a local Gem. While installing the internet must be disconnected. Wait for some time, as it will need time.

gem install <gem-name>

Install-a-local-Gem

 

Step 5: At last, local Gems are created. Now, local Gems details can be checked. The following command should be run to check the details of the newly created local Gems. Hence, the local Gems are created successfully.

gem info <gem-name>

 Check-the-details-of-the-newly-created-local-Gems

 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads