Vendor everything in Merb

21 April 2008

I spent an evening trying to suss out how to use merb with all the gems unpacked into the local gem folder, turns out my problem was using

gem unpack <gemname>

in a local /your/app/gems folder does not work.

Instead you need to setup an entire new gem home within your merb app, complete with /bin, /doc etc. directories that gem is expecting. To set this up you just need to do the following inside your merb app.

mkdir gems

gem install <gemname> --no-rdoc --no-ri -i /your/app/gems

Note that if you install a gem with a dependency it will by default install all the dependencies as well. This means that installing merbful_authentication for example will also likely install the merb, merb-core and merb-more gems into your app local gems directory. I am not sure how you would proceed using gems that compile for local architectures (mongrel, hpricot, eventmachine etc.) which might get dragged in as dependencies but then end up being bundled with your project. The obvious problem there is your development and production environments (and possibly different developers environments) are likely to differ so checking a platform specific binary into source control isn’t the best idea.

It is important to note the --no-rdoc and --no-ri flags as these will stop you having a doc directory of documentation generated from every gem that you install to your app. You can alternatively set up your .gitignore or svn:ignore to not check these in to source control, but I prefer to just never generate them in the first place.


Comments

Sorry, comments are closed for this article.