Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

GemRequireError obscures true cause of exceptions #4374

Closed
inglesp opened this issue Mar 16, 2016 · 3 comments
Closed

GemRequireError obscures true cause of exceptions #4374

inglesp opened this issue Mar 16, 2016 · 3 comments

Comments

@inglesp
Copy link

inglesp commented Mar 16, 2016

When running a spec, I hit the following exception:

$ ./bin/rspec spec/lib/record_handler_spec.rb 
/Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:83:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'statsd-instrument'. (Bundler::GemRequireError)
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
    from /Users/peteringlesby/work/openc/morph/config/application.rb:14:in `<top (required)>'
    from /Users/peteringlesby/work/openc/morph/config/environment.rb:2:in `require'
    from /Users/peteringlesby/work/openc/morph/config/environment.rb:2:in `<top (required)>'
    from /Users/peteringlesby/work/openc/morph/spec/spec_helper.rb:6:in `require'
    from /Users/peteringlesby/work/openc/morph/spec/spec_helper.rb:6:in `<top (required)>'
    from /Users/peteringlesby/work/openc/morph/spec/lib/record_handler_spec.rb:1:in `require'
    from /Users/peteringlesby/work/openc/morph/spec/lib/record_handler_spec.rb:1:in `<top (required)>'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `each'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load_spec_files'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:80:in `run'
    from /Users/peteringlesby/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun'

By adding a puts statement to runtime.rb, I found that the actual exception raised was uninitialized constant RSpec::Matchers::Composable. However, this was not at all obvious from the error message.

@inglesp
Copy link
Author

inglesp commented Mar 16, 2016

Replacing these lines with a bare raise caused the real exception to be raised.

I think this is much more useful behaviour. Would you accept a pull request for this?

@RochesterinNYC
Copy link
Contributor

This behavior should be fixed by #4187, which isn't part of v1.11.2. It'll be in the upcoming v1.12.0 release.

@inglesp
Copy link
Author

inglesp commented Mar 16, 2016

Good stuff!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants