eddorre

Deploying to Heroku using Bundler with Named Groups

I recently ran into a problem deploying my blog app (Rails version 2.3.8) to Heroku when I switched to Bundler. I’ve separated my Gemfile into sections such as development and test. The theory here is that when an application is deployed into production, Bundler will ignore those gems and they won’t be installed on the production environment.

Since deploying to Heroku’s platform has been extremely painless ever since I switched to it, I figured using Bundler would equally painless. Unfortunately, I ran into some errors as it tried to install gems from my test environment into production. Normally, this would not be such a big deal, but in this case a few of my gems (namely autotest-growl and autotest-fsevent) are OS X specific and cannot be installed on the Heroku platform.

The error that was returned was similar to this one:


/usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:482:in 
`build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) 

/usr/ruby1.8.7/bin/ruby extconf.rb 
extconf.rb:19: Only Darwin (Mac OS X) systems are supported (RuntimeError) 

Heroku’s official documentation states that they are aware of the issue and they are working with the Bundler team to get this out with Bundler’s 1.1 release. Unfortunately, that doesn’t help me (and I suspect others) now.

There are some hacks out there that some people have used successfully, but they all seemed, well like too much of a hack. I felt that there should be a better way.

Luckily, my good friend Matt Willhite (@MiWillhite) sent me a message that was passed onto him from Heroku Support. The trick is to add a configuration flag to Heroku with the following command:


heroku config:add BUNDLE_WITHOUT="development:test" --app app_name

Once I ran that command, I was able to deploy my application with Bundler behaving itself by installing only the gems that I needed.

Looks like the official Bundler documentation has been updated to include the suggested fix above.


Comments

Comments are closed

Comments are closed on this post. If you have something on your mind regarding this post, don't hesitate to drop me a line.