Bundler and deploying difficult to build gems

Posted: August 6th, 2010 | Author: | Filed under: ruby, web | Tags: , , | 3 Comments »

With Bundler 1.0.0.rcx you can specify the build options for gems. This is nice because certain gems (mysql, rsruby) are sometimes painful to build.

There is a bit of manual labor here which could be automated in some way you’d think, but for now it does work and that’s good enough for me.

  1. Login as your deploy user.
  2. Go to the deploy current directory where there is a Gemfile.
  3. type ‘bundle config build.mysql –with-mysql-config=/usr/local/bin/mysql_config’

This will now append the commands to the end of the build command for mysql allowing it to build when you deploy your application. It works quite well and I think it’s a simple solution for one of the biggest issues I had with trying to use Bundler in production.

The ‘bundle config’ step also creates a .bundle/config in the user’s home directory that will then use those options for all bundle builds of that gem on the server. So if you’re installing 4 different apps on the server, you’ll only have to setup that command once and bundler will pick it up on each deploy.

Some examples
bundle config build.mysql --with-mysql-config=/usr/local/bin/mysql_config
bundle config build.rsruby --with-R-dir=/usr/local/lib/R/
bundle config build.rmagick --no-ri --no-rdoc

To view the options you can also type ‘bundle config’ alone in a directory that contains a Gemfile. (Not sure why it needs a Gemfile to exist, but again, not a hard requirement)


I beat Dreamhost. How to really get rails 3, bundler and dreamhost working.

Posted: May 17th, 2010 | Author: | Filed under: ruby, web | Tags: , , , , | 13 Comments »

Please check out my earlier post so you can get the whole git/capistrano setup working as well.

So I’ve been trying to get rails 3 running with bundler on Dreamhost for a while. I’ve had a few posts on here about how to do it. In the end, they didn’t work completely. I’ve sent requests into Dreamhost to upgrade rubygems to 1.3.6 so the newest versions of bundler would work. I was told ‘No’ but go to this wiki site.

I wasn’t too happy about that since the top of the page has a big warning ‘DON’T DO THIS’. If you’re here looking at this you probably have the tech knowhow to do this and realize the world won’t end when you do.

So here’s the step by step directions for how I got it working.
You can check out the original wiki instructions at http://wiki.dreamhost.com/RubyGems.

Add this to your .bashrc
This will setup your shell to use local gems installed in your .gems directory, setup the path to check there first and opt/bin as well. Next we need to install a newer version of rubygems.

This will get rubygems installed and make sure you run your version before dreamhost’s. You then install bundler and rake. These are the only two gems I install in the system as I prefer to have all of my apps use their own gem versions. Putting everything into system is a big mess and a dependency nightmare on updates.

Next we need to make sure your app is setup to use the bundler gem. You need to modify your environment.rb and boot.rb

Make sure you change the application name to your name. Really you’re only adding the single line for the GEM_PATH

I was using the suggestions in the wiki but I eventually figured out that Dreamhost wasn’t properly picking up my gems even with the changed GEM_PATH. Adding the ‘Gem.clear_paths’ to boot.rb allowed the gems to be seen. This is what finally cracked the problem.

Hopefully this works for you.


dreamhost, please upgrade rubygems

Posted: April 30th, 2010 | Author: | Filed under: ruby, web | Tags: , , , | 2 Comments »

I’ve posted before about trying to use rails 3 with bundler and dreamhost. This is now not possible. The shared servers for dreamhost use rubygems 1.3.5. In order to use the current version of bundler you need rubygems 1.3.6.

If you are a dreamhost user please make sure to vote up the install rubygems 1.3.6 suggestion from the panel (panel.dreamhost.com) For a company that has been good about supporting ruby and rails this is something that needs to get fixed ASAP.


bundler times two

Posted: February 24th, 2010 | Author: | Filed under: ruby | Tags: , , , | No Comments »

I wish they would have made a bigger deal about this, but it seems that bundler now has two different gems.

bundler08 is for bundler 0.8.4 and such, which plays really well with rails 2.3.5

bundler is for bundler 0.9.x and beyond which plays well with rails 3 (and rails 2.3.5 if you can get it to work…)

This is a really good thing because you can now install both of them at the same time and the warning that you must un-install all previous versions of bundler is now moot. Really helpful if you’re running on dreamhost with mixed rails 2/3 sites.


bundler and rails 2.3.x

Posted: February 9th, 2010 | Author: | Filed under: ruby, web | Tags: , | No Comments »

Seems I was missing a few things.

Take a look at this gist and see if it can help you.

Edit: Updated the gist to a better one.


bundler and future updates

Posted: February 9th, 2010 | Author: | Filed under: ruby, web | Tags: , , , | No Comments »

There was a new post about bundler which addresses a few of the issues that I’ve been having as part of my install.

When running bundle install in the future, Bundler will use packed gems, if available, in preference to gems available in other sources.

This will be nice and solve my issue of re-installing all the gems on each deploy.

You will want to run bundle unlock to remove the lock, then bundle install to ensure that the new dependencies are installed on your system, and finally bundle lock again to relock your application to the new dependencies.

We will add a command in a near-future version to perform all these steps for you (something like bundle install –relock).

This will also replace the unlock, update, lock steps I’ve got in the callbacks.rb for my deploy scripts. Not a huge deal, but fewer commands is better.

The combination of these two updates should speed up the deploy a lot.


rails 3, bundler, git and dreamhost

Posted: February 8th, 2010 | Author: | Filed under: ruby, web | Tags: , , , , | 1 Comment »

UPDATE: How to setup your Dreamhost shell account update available here.

Now that rails 3 has hit beta, I decided to see if I could get it running on my dreamhost account. I’m already running a few rails applications using bundler 0.8.1, so the forced upgrade to 0.9.3 (as of this writing) is actually a point of pain, since both versions cannot co-exist.

If you’re not running an old version of bundler, this should be an easy update. If you are, it gets complicated to the point that for now, it’s not worth updating since bundler 0.9.3 still seems to have issues with rails 2.3.x.

The first thing I did was to install the bundler gem in your usual location for dreamhost. This isn’t going to be a “how do I set up rails and custom gems for dreamhost?” post as those resources exist on the web already.

On dreamhost:
gem install bundler

Now you want to setup your rails 3 application, get it into a git repository and push it there. The main point of this post is to include my deploy files which are based on the github ‘git’ deploy strategy, which is really nice. I’ve added in some code for jammit as my asset packager, and some custom bundler callbacks.

I’ve included a gist below with my deploy code. Make sure the files are in the proper directories.