carlhuda/bundler — pull request #2019 by luismreis (2012-07-08 14:05:52+00:00)
Title: Properly handle missing binary libraries.

After removing a binary library dependency from my project (in this case: libffi), bundler started to crash on simple commands as:

rake -T

Error message:

rake aborted!
undefined method `gsub' for nil:NilClass
...

Running rake with --trace yields:

rake aborted!
undefined method `gsub' for nil:NilClass
/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:77:in `rescue in rescue in block in require'
/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:72:in `rescue in block in require'
/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:62:in `block in require'
/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `each'
/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `require'
...

After applying this patch, running ```rake -T``` yields:

rake aborted!
dlopen(/.rvm/gems/ruby-1.9.3-p194@/gems/ffi-1.0.11/lib/ffi_c.bundle, 9): Library not loaded: /opt/local/lib/libffi.5.dylib
Referenced from: /.rvm/gems/ruby-1.9.3-p194@primal/gems/ffi-1.0.11/lib/ffi_c.bundle
Reason: image not found - /.rvm/gems/ruby-1.9.3-p194@primal/gems/ffi-1.0.11/lib/ffi_c.bundle

I couldn't find tests for these kinds of errors, but if they exist and someone can give some directions, I'll add tests to the patch.