Open In App

How to Install a local gem in Ruby?

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:



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

 

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

 

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>

 

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>

 

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>

 

Article Tags :