Ruby - Bundle Install/Update Too Slow

Bundler, when attempting to update or install, will hang forever

This problem is due to a missing dependency, or worse a dependency-of-a-dependency. It's common when you don't use rubygems.org as your gemserver (an enterprise environment).

Common patterns:

  • You don't have that gem installed
  • You don't have the dependencies of that gem installed
  • You don't have that gem installed without its dependencies

Easiest Technique

create a new gemset, and re-bundle. This fixes the problem many times.

If you can't do that for production reasons, and you don't have an app history from which to reflect on when the problem gem was added, then:


Easier Technique

Having learned a bit since writing this answer, I thought I'd pass on this excellent article for how to run bundler with verbose debug output

export DEBUG_RESOLVER=1
bundle 2> debug_output.txt 1> stdio.txt &

This will dump all the debugging (err) output to debug_output.txt and the normal screen stuff to stdio.txt.

You'll want to dump 1> as well because every time bundler dumps a line to 2(stderr) it will put a crlf into 1. So Either dump 1 or background the job. I do both so I can work in the same terminal.

I usually follow it up with:

tail stdio.txt 

to be sure things have started, then:

tail -n 10000 -f debug_output.txt 

To search with /FAIL] through the file for failed attempts to install a dependency. Find a couple of them that are the same and you've generally located your culprit. The stderr works for bundle install or bundle update.


Debug Your Private Gemserver Technique

I needed to use this process-of-elimination method to determine that my (enterprise) gemserver index had become corrupted

  1. comment out all gems
  2. run bundle update to confirm the empty-set works
  3. un-comment one gem and bundle update
  4. GOTO 3 until you hit the problem
  5. research its dependencies

When you are done

Unset the ENV var with

unset DEBUG_RESOLVER

Longer bundle update install time

If it's taking more than a minute or so then there's a problem of some sort that should be cleaned up.

First follow the options here:

https://github.com/carlhuda/bundler/blob/1-0-stable/ISSUES.md

To summarize the steps for you, follow these:

# remove user-specific gems and git repos
rm -rf ~/.bundle/ ~/.gem/

# remove system-wide git repos and git checkouts
rm -rf $GEM_HOME/bundler/ $GEM_HOME/cache/bundler/

# remove project-specific settings and git repos
rm -rf .bundle/

# remove project-specific cached .gem files
rm -rf vendor/cache/

# remove the saved resolve of the Gemfile
rm -rf Gemfile.lock

# try to install one more time
bundle install

This will clear most any issues with your installation and give you a clean starting point to work from. Good luck!

`bundle update rails` takes hours

I found the solution after running DEBUG_RESOLVER=1 bundle install.

There was a circularity going on where Rails would begin at v 3.2.13, then it would be changed to 3.2.14 to resolve a dependency, then it would be changed back on the next pass. So, it seems all that time it was toggling back and forth.

I manually changed the versions in my Gemfile to eliminate the circularity that I saw in the logs, and that ended up fixing the issue.

Why is bundle adding an extra 0 at the end of my Ruby version?

Seems like this may have been due to a conflict between gem installed gems and bundle installing the same gems over again.
Doing gem uninstall -aIx and then bundle install may fix this.

Bundler takes forever

Probably either you have network problem, or the gem server is down. If it is the former, then fix it. If it is the latter, then wait until it is working.



Related Topics



Leave a reply



Submit