Bundling Gems With Merb
As part of the deployment of my first Merb app I wanted to make sure it contained everything it would need. This is pretty easy in Merb:
thor merb:gem:install
Once that runs through and bundles all the gems in your dependencies.rb file I knew that I should have been able to simply run:
./bin/merb
and use the bundled install of Merb. But this was failing mightily with dramatic FATAL errors. Using:
./bin/merb --verbose
shed light onto the issue. It turns out that because I was doing all my development by just running merb Merb was loading necessary dependencies that I hadn’t specified explicitly in my dependencies.rb file. Dependencies like “rmagick” and “mongrel”.
Putting all the dependencies into the file and re-running thor merb:gem:install did the trick.
Incidentally, if you attempt to do something like:
thor merb:gem:install mongrel
without having mongrel specified in dependencies.rb the install will fail. This, in hindsight, makes perfect sense to me – I like that file being the authority – however the error message generated is a bit obtuse ( in this case: "Configuration could not be confirmed: Could not find RubyGem mongrel (>= 0)").
It also appears (though I’m surprised by this so I suspect my understanding of this process is suspect) that you’ll need to declare dependencies that dependent gems rely on. Again in my case to get gruff bundled I also had to define rmagick:
dependency "rmagick", "2.9.0" dependency "gruff", "0.3.4"
So if you’re bundling gems make sure they’re all explicitly defined and use –verbose when running Merb to double-check. And read Getting Started with Merb – Bundling Merb with your Application. It was immensely helpful.