Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Don't display the "fatal error" warning for illformed Rubygem requirements #1542

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants

arsduo commented Nov 18, 2011

Right now, if a developer makes a mistake in their Gemfile (for instance, entering ">~ 3.1" rather than "~> 3.1"), Rubygems raises an ArgumentError. Bundler passes that error along, but also adds a red-colored message asking users to report the problem on Github:

Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
/Users/ahkoppel2/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:98:in `parse': Illformed requirement [">~ 3.1.1"] (ArgumentError)

The "fatal error" message (raised in bin/bundle) probably shouldn't be raised in this case, since the error was caused and has to be fixed by the user. This small pull request skips that warning if it detects this particular Rubygems error message (which has been the same since at least 2009, according to blame).

For reference, the relevant method in Rubygems is here; I've also submitted a pull request to raise a specific error class so that Bundler wouldn't need to do text comparison on the error message, on the off chance it ever changes.

Thanks for the great work!

Alex

Complete backtrace:

Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
/Users/ahkoppel2/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:98:in `parse': Illformed requirement [">~ 3.1.1"] (ArgumentError)
    from /Users/ahkoppel2/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:123:in `block in initialize'
    from /Users/ahkoppel2/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:123:in `map!'
    from /Users/ahkoppel2/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:123:in `initialize'
    from /Users/ahkoppel2/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:61:in `new'
    from /Users/ahkoppel2/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:61:in `create'
    from /Users/ahkoppel2/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:50:in `initialize'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/dependency.rb:28:in `initialize'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/dsl.rb:60:in `new'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/dsl.rb:60:in `gem'
    from /Users/ahkoppel2/Sites/project_name/Gemfile:3:in `evaluate'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/dsl.rb:7:in `instance_eval'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/dsl.rb:7:in `evaluate'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/definition.rb:17:in `build'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler.rb:144:in `definition'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/cli.rb:219:in `install'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/vendor/thor.rb:263:in `dispatch'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/lib/bundler/vendor/thor/base.rb:386:in `start'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.rc/bin/bundle:13:in `<top (required)>'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `load'
    from /Users/ahkoppel2/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `<main>'
Contributor

rohit commented Nov 11, 2012

This has been fixed on latest versions of Bundler, version 1.2.1 outputs the following ―

(~/code)९ bundle
/home/rohit/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:81:in `parse': Illformed requirement [">~ 1.0"] (ArgumentError)
.
.
snip
.
.

There was an error in your Gemfile, and Bundler cannot continue.

@rohit rohit closed this Nov 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment