Installing a gem fork from Github source
Usually, installing a gem is as easy as issuing:
gem install gem_name
but, what if you want to install a fork of a gem?
As you may know Github no longer hosts gems, so doing the following won't work:
$ sudo gem install technoweenie-grit --source http://gems.github.com
NOTE: Actually it'd work if the gem you're trying to install is in this list: http://gems.github.com/list.html
Disecting the "Download Source" button
Let's suppose we want to install the Techno Weenie's fork of Grit from Github:
Main repo => http://github.com/mojombo/grit
Techno Weenie's fork => http://github.com/technoweenie/grit
Github has a "Download Source" button, if you click it you'll be presented with two big images (say buttons): "ZIP" and "TAR", clicking these buttons will start downloading the code of the master branch in the selected format; below those buttons you'll find the list of tags of the repository, you'll be able to click one of the tags and again you'll be presented with "ZIP" and "TAR" to download the source of such tag.
How does this works?
This is how the URL is built:
http://github.com/USER/REPOSITORY/FORMAT/BRANCH_OR_TAG
"ZIP" => http://github.com/technoweenie/grit/zipball/master
"TAR" => http://github.com/technoweenie/grit/tarball/master
said this:
$ wget http://github.com/technoweenie/grit/zipball/master $ unzip technoweenie-grit-v2.0.0-12-g0bd0c5f.zip $ cd technoweenie-grit-0bd0c5f
Installing the gem
Gems source code has a special file called gem_name.gemspec, this is like the DNA of the gem and it's used to build it:
$ gem build grit.gemspec
Issuing this command will generate a gem_name-version.gem file which is the gem itself, let's install it:
$ sudo gem install grit-2.0.0.gem
Some projects doesn't have a .gemspec file but rake tasks, in that case you just need to do:
$ rake build $ rake install
If any of these methods work, you'd have to look at the Rakefile for tasks to generate the .gemspec file.
...and we're done!
NOTE: 'gem build' will not take in consideration special and external dependencies the gem might require, so you must take care of the dependencies manually. Check in the code all the 'require' lines to see dependencies.
Hope it helps.
Does anyone knows an easier method?
November 2nd, 2010 - 12:17
As someone who is familiar with the Ruby scene, can you advise someone who is trying to get into it?
http://stackoverflow.com/questions/4058449/outdated-ruby-gem-how-do-i-share-my-changes
I want to update this GEM so I can use it, but also let others download it. If I have to fork at this point, so be it. If not GH, where do I go with abandoned code (this has not been touched since 2006)?
November 2nd, 2010 - 13:31
I’ve read the thread in stack overflow and based on what I read this is what I’d do:
1. Clone (RubyForge) the code of the gem you want and host it somewhere else (I’d recommend GitHub)
2. Add some comment to the new clone to let the people know that isn’t entirely your work and credit the author.
3. Add a link to the RubyForge page as well
4. Start commiting your changes
5. Release the gem with a new name like pdf-tools or alharaka-pdf-toolkitor whatever you want.
6. That’d be it.
November 3rd, 2010 - 01:21
Thanks for the advice. I was just unsure of what the preferred “Ruby” was of doing things is these days. It seems the possible environments have changed a lot.
October 28th, 2010 - 02:35
OK, this works, but I end up with something that doesn’t run:
jean@klippie:~/repos/git/Pivotxt$ gem build pivotxt.gemspec
[...]
Successfully built RubyGem
Name: pivotxt
[...]
jean@klippie:~/repos/git/Pivotxt$ gem install pivotxt-0.1.0.gem
WARNING: Installing to ~/.gem since /var/lib/gems/1.8 and
/var/lib/gems/1.8/bin aren’t both writable.
WARNING: You don’t have /home/jean/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Successfully installed pivotxt-0.1.0
1 gem installed
Installing ri documentation for pivotxt-0.1.0…
Installing RDoc documentation for pivotxt-0.1.0…
jean@klippie:~/repos/git/Pivotxt$ /home/jean/.gem/ruby/1.8/bin/pivotxt
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’: no such file to load — treetop (LoadError)
November 2nd, 2010 - 09:06
well, it seems the guy which made the pivotxt gem didn’t declare the dependencies, one of those is treetop, since treetop is not declared as dependency you have to install it manually:
$ sudo gem install treetop
that should work. Thanks.
July 19th, 2010 - 15:14
This might help you http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/
July 19th, 2010 - 15:34
Hi, Cynthia, sadly the Dr. Nic’s approach doesn’t work for all the rubygems hosted in Github, it used to, in the Gemcutter times, but it doesn’t longer work for all the gems, only for a few of them. Thanks, though!