Bundle Me Some Sanity
Wed Mar 31 21:40:44 -0700 2010
You know, there are these two guys working in broad daylight on Bundler, Yehuda and Carl (he’s the one in the sidecar), but I don’t think people have really grasped the importance of what they are doing.
Bundler is just as mind blowing a development for Rails 3 as any other change in the Rails framework. As the wycats states; “Bundler manages an application’s dependencies through it’s entire life across many machines systematically and repeatably”.
To me, bundler takes the guess work out of dependency management, it simply provides you with a way to know what gems you are distributing with your application, we (as a Ruby community) have never had such a comprehensive solution to gem management before.
But like any new tool, it is going to go through some growing pains. To my surprise, (and the credit of the authors) the growing pains have been short and sharp, rapidly fixed as bundler grows to whole new levels of reliability.
And also like any new tool, it is optimised for certain environments, in bundler’s case, USE RVM! If you are not using RVM and you are running multiple rubies with Bundler, honestly, you’re mad. Do yourself a favour, download RVM and use it. You can then specify sand boxes of gem sets for each ruby or application you have, goodbye incompatible gems conflicting with each other.
To give you a taste of just how awesome the Bundle RVM marriage is, check this out:
After you install RVM, go into the directory of each app you want to have their own private gem sets and create a file called .rvmrc and put in there:
rvm ruby-1.8.7@railsplugins
Which is what I have on my RailsPlugins.org repository.
Then change into the directory, and RVM will tell you it doesn’t know about the gemset:
$ cd railsplugins Gemset 'railsplugins' does not exist, rvm gemset create 'railsplugins' first.
OK, so go ahead and create the gemset and have a look at what gems you have installed:
$ rvm gemset create 'railsplugins' Gemset 'railsplugins' created. $ gem list *** LOCAL GEMS *** $ ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10.2.0]
Good… see? A clean ruby 1.8.7, as if you just bought the computer.
Now go ahead and install bundler for this clean gemset:
$ gem install --no-rdoc --no-ri bundler Successfully installed bundler-0.9.14 1 gem installed
Cool, now all that we have left is to give bundler the reins and tell it to do what it does best:
$ bundle install <lots of output>
Now when you gem list for that directory you will get all the gems in your gem file, and when you move to a different directory (with a different .rvmrc) all your gems get magically switched out for the new set.
Honestly, with the number of different clients I am coding for and the number of libraries I am working on, I can’t imagine being any where near as productive without the RVM and bundler team.
Yehuda has made a fairly comprehensive guide to bundler at the Gem Bundler site which you should read through and understand, and I have only brushed the surface of RVM, you should check it out as well at the RVM site
blogLater
Mikel




Thu Apr 01 01:07:28 -0700 2010
thanks for the post, but whenever I cd into my project directory, rvm just promts:
ruby ruby-1.8.7@project_a is not installed.
To install do: ‘rvm install ruby-1.8.7@project_a’
the content of my .rvmrc is:
rvm ruby-1.8.7@project_a
and rvm —version is:
rvm 0.1.24 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
any ideas?
Thu Apr 01 01:09:41 -0700 2010
thanks for the post, but whenever I cd into my project directory, rvm just promts:
ruby ruby-1.8.7@project_a is not installed.
To install do: ‘rvm install ruby-1.8.7@project_a’
the content of my .rvmrc is:
rvm ruby-1.8.7@project_a
and rvm —version is:
rvm 0.1.24 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
any ideas?
Thu Apr 01 01:13:40 -0700 2010
Sorry for the comment spam..
turns out that the @ separator for gemsets is a new feature in 0.1.25 (used to be ‘%’) which can be installed using rvm udate —head
cheers
Thu Apr 01 04:00:07 -0700 2010
@pascal Yes, get head often: `rvm update —head` It moves fast. Any questions/issues when using ask me in #rvm on irc.freenode.net
@mikel I have some additional notes for you,
In the .rvmrc example if you change this:
rvm ruby-1.8.7@railsplugins
To this:
rvm —create ruby-1.8.7@railsplugins
Then it will create the gemset when you enter the directory if it does not exist. (read more here: http://rvm.beginrescueend.com/gemsets/ )
I am currently talking with Yehuda about the feasibility of adding Bundler into RVM for gem management by default as well as adding `rvm bundle ` to iterate against all or selected installs.
Awesome writeup Mikel!!!
~WayneThu Apr 01 04:41:44 -0700 2010
Thanks for the tip Wayne :) Thanks for RVM too!
Thu Apr 01 04:42:46 -0700 2010
Great post. RVM is really awesome.
Thu Apr 01 08:15:51 -0700 2010
Great tips! thanks – I needed that – you just pushed me far enough to now (finally) go look at RVM.
By-the-way: I think that should be “good-bye incompatible gems…” – took two reads of that sentence to realize what you meant.
Thanks!
Thu Apr 01 08:50:15 -0700 2010
Your post is linked at www.DrinkRails.com drink#26
Thu Apr 01 14:04:21 -0700 2010
@John thanks for the typo spotting, fixed :)
Sat Apr 03 10:48:06 -0700 2010
If you want an app to have it’s own gemset, it’s smoother just to do this:
cd railsdir && bundle install vendor/bundle
That also makes a railsdir/.bundle file where the bundle stuff is specified specifically for that dir. Check it in to your repo, and you’re set.
Tue Nov 08 19:45:09 -0800 2011
That also makes a railsdir/.bundle file where the bundle stuff is specified specifically for that dir. Check it in to your repo, and you’re set.
Wed Jun 30 11:34:23 -0700 2010
Thanks for your article, after reading it took me a while to learn the whole process of using rvm with bundler in the best way, so I took time to write out more detailed instructions for managing gems with RVM and Bundler. I hope that helps someone. Also check out eddorre’s version and a nice tip from Brian on auto-creating gemsets with .rvmrc.
Thu Apr 28 17:13:41 -0700 2011
railsdir/.bundle file where the bundle stuff is specified specifically for that dir. Check it in to your repo, and you’re set
Sun Jan 01 20:53:45 -0800 2012
I am currently learning how to use Rail and this bundle will be useful in the future when I learn how to use now.
Wed Jan 04 00:49:48 -0800 2012
Rail is such a fun code to learn and use because its very versatile
Tue Jan 31 04:20:04 -0800 2012
The best person to give you medical advice about liver disease is your doctor. Best thing we can do is recommend perhaps a good doctor if you need a second or third opinion. casino