Skip to content

Bundler, demystified.

2010/09/29

Really, there’s nothing all that mysterious about Bundler, at least not for managing local dependencies.

In your project folder:

$ bundle init

Then, edit your Gemfile:

vi Gemfile

and add the gems your project depends on (direct dependencies only, if you please) like this

gem “name_of_your_awesome_gem”

Then, simply run the command

$ bundle install

The authors of Bundler recommend keeping Gemfile & Gemfile.lock under version control.  While not mandatory, it makes sense.  If you’re using git, which I can’t recommend enough, a simple

git add Gemfile Gemfile.lock

should do the trick.

Now (the correct versions of) your application’s dependencies will be locked in.   This could just as easily been done using another tool, RVM Gemsets, for example.  However, Bundler does offer a few other advantages.  When the time comes to deploy, it’s possible to use Bundler to package dependencies with your application.   As well, if you’re not using RVM, you can still use Bundler to make sure your application always loads the correct set of gems (and appropriate versions thereof.)

There are the basics, wrapped up in a nice little package (bundle?), hopefully this will help to improve your daily development practices.  It certainly has mine.  Happy Hacking!

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: