Manage Gems Separately in Different Projects Use Bundler

RubyOnRails 3 七月 2010 | View Comments

Before we use bundler, we unpack all dependencies into vendor folder. But we found it hard to use, especially one of your gem require rubygems in code, yes it happens.

The killer feature bunlder has in my view is: you can install gems in any folder, that’s means you can install gems into your project folder directly. So each of your projects will has it’s own gemset.I think this is a better solution than use rvm to create separate gemset for each project(see my previous entry).

If you have already installed bundler, or you have already using bundler, you can skip the first part, go bundler for passenger directly

Upgrade Your Gem

First, check whether your gem version >= 1.3.6, if not upgrade your gem

  • For mac user, just gem update --system
  • For linux user:
    1. Install rubygems-update gem gem install rubygems-update
    2. Upgrade rubygem, run ./bin/update_rubygems, if it says: “can’t find command”, you can go to your gem EXECUTABLE DIRECTORY which you can get by run command gem environment

Install bundle

Install bundler using gem install bundle, as this blog wrote, bundler verison is 0.9.26

Manage your gems use bundle

There are good documents on bundler website, you can check the basic usage there. I’ll not mention here.

ok, let’s do it.

bundle install .bundle

Yes, that’s it. Now your gems will only live in your project folder. It’s very sweet when you need deploy multi projects on one machine.

Bundler with passenger

After you deploy your bundler enhanced project with passenger, passenger will yelling: please gem install bundler.
the solution is add gem dependencies in Gemfile. Yes it’s strange, but I google about it, I haven’t better solution, if you know you can tell me.



Tagged in , , , ,

Ads Plugin created by Jake Ruston's Wordpress Plugins - Powered by and football database.