views:

83

answers:

2

I am trying to hack through a forked gem (buildr). As such I cloned it from github and began to butcher the code. The official gem is installed on my system (under /usr/lib/ruby.../gems/buildr...). There is an executable which I need to use in my dev process - buildr.

Now I want the buildr executable and the library to point to my forked repo and not the default gem installation. This would be for this gem only. As such, the changes I make against the forked repo is usable directly for testing and so forth.

I would guess I need to load my library prior to the system gem loading. Can somebody recommend the best way to do so?

A: 

I did something similar for work when the Spreadsheet gem broke backward compatibility. I put the previous versions code in it's own module and just renamed the gem my-spreadsheet and installed that (I really wanted some of the features of the new gem but I also didn't want to rewrite all my previous code at that point).

If it's just a binary you want to override you could always do some PATH magic, setting the directory of your binary first and thus make sure you always override. But personally I'd prefer making my own copy with a new name and installing that.

ba
A: 

you could bump the version in the gemspec for your fork. Then when you install your version of the gem, it will use your (newer) version by default.

change buildr.gemspec

#...
  spec.version        = '1.3.4.dev'
#...

Then

$ gem build buildr.gemspec
$ sudo gem install buildr-1.3.4.dev.gem

and it should work.

BaroqueBobcat
that would still mean I need to install the gem each time I do a change. Is it not possible to point gem to load the staging gem from the source instead of loading the installed one?
Carl
You could install it, then replace the `.../ruby/gems/1.8/gems/buildr-1.3.4.dev` directory with a symlink to your source that you are modifying. It is pretty hacky, but would work. You'd want to be careful about permissions then.
BaroqueBobcat