xplpua
17.62K
· November 2013 ·
2014 07 31 18.14.34 hdr

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.

Sign in or sign up to add your response.

8 Responses

10518

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

over 1 year ago ·
10523
7297c7484eb236c1b961b788f7a37112

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 ·
10526
2014 07 31 18.14.34 hdr

Noted!

over 1 year ago ·
10539

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

gem install bundler --pre
over 1 year ago ·
11131
8e2b996de3842c6ef7e68a82fa5f01f5

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 ·
11132
8e2b996de3842c6ef7e68a82fa5f01f5

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 ·
11230
56acf3dce9676364b491eae7ecd736e6

Neat. Works pretty good.

over 1 year ago ·
12345
0e8a012c6542299bec2bc94922a3ed27

i wonder why bundler doesn't do this by default

over 1 year ago ·
Featured Programming Job

Principal Full Stack Rails Engineer/Manager
·
San Francisco, CA; Remote USA
·
Full Time
Search all programming jobs