[ACCEPTED]-Forking a gem for a Rails project-gem

Accepted answer
Score: 107

Today this is pretty easy to do with Bundler. You 10 make a local copy of the gem and then instead 9 of doing

gem "whatever"

in your Gemfile, you do:

gem "whatever", :path => "/home/pupeno/whatever"

After running 8 bundle install, the gem is picked from that 7 directory. Even if you modify something 6 in there, all you need to do to re-load 5 it is restart Rails.

If you need to deploy 4 an application using your own changes of 3 a Gem, you make a fork, on Github or similar 2 and on the Gemfile you do:

gem "whatever", :git => "git@github.com:/pupeno/whatever.git"

and that's it. It's 1 simple, straightforward and beautiful.

Score: 3

In all the cases the gems were at github 16 so I would probably for it at github, clone 15 it, make my chances and maintain my own 14 branch. I suppose then I would install that 13 branch directly with gem install on my server.

If 12 you really need to hack the actual gem source 11 then yes, that would be the way to do it. However, it 10 should be a last resort. You don't want 9 to maintain the actual gem if you don't 8 have to. Why not extend classes from the 7 gem source whose functionality you need 6 to change and use your classes instead of 5 the gem classes in your Rails code?

I find 4 it rare that you actually need to hack 3rd 3 party code directly to do what you need 2 to do. Good software can be extended/easily 1 augmented.

More Related questions