Tuesday, November 5, 2019
Installing Gems from Git Repositories
Installing Gems from Git Repositories Many gems are hosted on git repositories, such as the public repositories on Github. However, to get the latest version, quite often there are no gems built for you to install with ease. Installing from git is quite easy though. First, you have to understand what git is. Git is what the developers of the library use to track the source code and to collaborate. Git is not a release mechanism. Its important to note that the version of the software you get from git may or may not be stable. Its not a release version and could contain bugs that will be fixed before the next official release. The first thing you have to do in order to install gems from git is install git. This page of The Git Book explains how to do this. Its rather straightforward on all platforms and once its installed, you have everything you need. Installing a gem from a Git repository is going to be a 4 step process. Clone the Git repository.Change to the new directory.Build the gem.Install the gem. Clone the Git Repository In Git lingo, to clone a git repository is to make a copy of it. Were going to be making a copy of the rspec repository from github. This copy will be a full copy, the same the developer will have on their computers. You can even make changes (though you wont be able to commit these changes back into the repository). The only thing you need to clone a git repository is the clone URL. This is provided on the github page for RSpec. The clone URL for RSpec is git://github.com/dchelimsky/rspec.git. Now simply use the git clone command provided with the clone URL. $ git clone git://github.com/dchelimsky/rspec.git This will clone the RSpec repository into a directory called rspec. This directory should always be the same as the final part of the clone URL (minus the .git part). Change to The New Directory This step, too, is very straightforward. Simply change to the new directory created by Git. $ cd rspec Build the Gem This step is a bit more tricky. Gems are built using Rake, using the task called gem. $ rake gem It may not be that simple though. When you install a gem using the gem command, silently in the background it does something rather important: dependency checking. When you issue the rake command, it may come back with an error message saying it needs another gem installed first, or that you need to upgrade a gem already installed. Install or upgrade this gem using either the gem command or by installing from git. You may have to do this several times depending on how many dependencies the gem has. Install the Gem When the build process is completed, you will have a new gem in the pkg directory. Simply give the relative path to this .gem file to the gem install command. Youll need administrator privileges to do this on Linux or OSX. $ gem install pkg/gemname-1.23.gem The gem is now installed and can be used just as any other gem.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.