Open In App

How to Install Gems from Git Repositories?

Rubygems is a package manager for the Ruby programming language. RubyGems provides a standard format to distribute Ruby programs and libraries, it is a tool designed to easily manage the installation of gems, and a server for distributing them. Git repositories contain project file tracks and save the versions of all the changes made to the files in the project. Git repositories can be cloned on a local machine for adding new features or for debugging purposes and changes were pushed to the origin in a git repository, it keeps track of the version and changes made in the files of the project.

Installing Gems from Git repository

Step 1: Clone the git repository.



git clone “url of the repository.*git”

Example,



git clone “https://github.com/dchelimsky/rspec.git”

 

Step 2: Change the directory to the cloned git repository.

cd ‘name of the git repo’

cd rspec

 

Step 3: Build Gem.

gem build gemname.gemspec -[OPTIONS]

Options

–platform PLATFORM – Specify the platform of gem to build

–force – skip validation of the spec

–strict – consider warnings as errors when validating the spec

-o, –output FILE – output gem with the given filename

-C PATH – Run as if gem build was started in instead of the current working directory.

gem build rspec.gemspec

 

Step 4: Install the gem.

gem install [options] gemname-version.gem

Options:

-h, –help – To help on this command

-V, –[no-]verbose – To Set the verbose level of output

-q, –quiet – Silence command progress meter

–silent – Silence RubyGems output

–config-file FILE – Use config file instead of default

–backtrace – Show stack backtrace on errors

–debug – Turn on Ruby debugging

–norc – Avoid loading any .gemrc file

gem install rspec-1.3.2.gem

sudo gem install respc-1.3.2.gem

 

Conclusion

git clone “URL of  repository”.git

 

cd “Name of the repository”

 

gem build gemname.gemspec [OPTIONS]

 

gem install [OPTIONS] gemname-version.gem

 

Article Tags :