Last Updated: November 12, 2020
· dickeyxxx

Make bundler crazy fast

Paralellize gem installs

You can paralellize the installation of gems with bundler's jobs feature.

To use, simply run:

bundle install --jobs 3

This only works for bundler 1.4 or above

Or to enable globally for all future bundling:

bundle config --global jobs 3

Obviously jobs is the number you want to parallelize. Pick the number one less than the number of cores you have. If you don't, you may get deadlock errors.

Credit to @xianpants for the tip!

Disable documentation

Create a file at ~/.gemrc with:

gem: --no-rdoc --no-ri

Unless, of course, you use local documentation.

8 Responses
Add your response

choose the number of cores that you have on your machine. That will (in most cases) be optimal.

over 1 year ago ·

This will only work in the current --pre versions (1.4)

$ gem install bundler
Fetching: bundler-1.3.5.gem (100%)
Successfully installed bundler-1.3.5
1 gem installed
$ bundle install --jobs 4
Unknown switches '--jobs'
over 1 year ago ·


over 1 year ago ·

As of Nov/3/2013, update to 1.4 (to use the parallelize feature) using:

gem install bundler --pre
over 1 year ago ·

Great idea with the global ~/.gemrc. I sometimes remember to add that flag when installing but very rarely.

However, the --no-doc and --no-ri flags are deprecated in Ruby 2.0. So, the ~/.gemrc might be slightly improved as:

gem: --no-document

I disabled Rubygem documentation in thoughtbot's dotfiles based on this tip, edited for Ruby 2.0.

over 1 year ago ·

I'm not someone who knows how many cores my machine has without looking it up. So, I think a slight improvement to the first line might be:

number_of_cores=`sysctl -n hw.ncpu`
bundle config --global jobs `expr $number_of_cores - 1`

That should automatically pick one number less than the number of cores on the machine.

I configured Bundler for parallel gem installs in thoughtbot's laptop script based on this tip, edited to dynamically use one number less than the number of cores on the machine.

over 1 year ago ·

Neat. Works pretty good.

over 1 year ago ·

i wonder why bundler doesn't do this by default

over 1 year ago ·