Sean’s Obsessions

Sean Walberg’s blog

Moving From Github to Gemcutter for Your Rails App’s Gems

Much hoopla has been made over Github stopping their gem building service, and for people to use Gemcutter.

All the stuff I’ve read has been that gemcutter is much better for publishing Gems, and that it’s easier to find the canonical gem (instead of deciding whether fred-mygem is better than barney-mygem)

Fair enough, but what about slobs like me that haven’t had to modify gems, and just want to start using the new source for gems and to update existing apps accordingly?

Turns out, it’s pretty easy.

1
2
3
4
5
6
# Update gem to at least 1.3.5
gem update --sytem
# install gemcutter
gem install gemcutter
# update gem sources
gem tumble

If you look at ~/.gemrc, you’ll see that github has been pushed to the end:

1
2
3
4
5
6
7
8
9
10
11
---
:benchmark: false
:verbose: true
gem: --no-ri --no-rdoc
:update_sources: true
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
:bulk_threshold: 1000
:backtrace: false

The last thing to do is to reinstall the old github gems using their new names. In environment.rb and environments/*.rb, look for your config.gem lines:

1
2
3
config.gem "thoughtbot-factory_girl",
       :lib     => 'factory_girl',
       :source  => 'http://gems.github.com'

Becomes:

1
config.gem "factory_girl"

Note that all you’re doing is taking off the owner of the gem, and then getting rid of the extra parameters.

It would be wise to first make sure that the gem is available on gemcutter. Browse to http://gemcutter.org/gems/GEMNAME, (eg http://gemcutter.org/gems/factory_girl) to see if you get an error.

Finally, run

rake gems:install
from within your app’s directory to install the new gems.

Presto! It’s easier than I thought.

Comments

I’m trying something new here. Talk to me on Twitter with the button above, please.