[Rubygems-developers] $VERBOSE and error messages

Chad Fowler chad at chadfowler.com
Sun Apr 18 09:25:22 EDT 2004

On 18/4/2004, at 12:58 AM, Gavin Sinclair wrote:

> I just added (but didn't commit) this code to the option parser in 
> bin/gem:
>       op.on('-v', '--verbose', "Give more verbose output in error 
> conditions") {
>         $VERBOSE = true
>       }

If we set $VERBOSE to true, won't it potentially create a lot of other 
output that we don't want?  I generally like what you're doing here, 
but I don't think we should mix the two VERBOSEs.  There might be 
something to be said for also showing ruby's VERBOSE output, but as an 
application user, I seldom want to see the details of what the 
underlying VM or interpreter is doing when I turn on verbose mode.

> And I have already added (and committed) this code to the "build" 
> operation:
>   rescue Gem::Exception => err
>     puts "Operation failed: #{err}"
>     puts err.backtrace if $VERBOSE
>   rescue => err
>     puts "Unexpected error: #{err}"
>     puts "Details:"
>     puts err.backtrace
>     exit!

This brings up a good point.  I think this is OK to add now (it matches 
similar things in the code), but I would like to generally see us pull 
all user interaction (like "puts", "print", and "get" in today's world) 
up into the level of the "gem" command.  A good example of why this is 
more than just an idealist desire is Curt's gem browser.  As of now, he 
would have to do an ugly hack to do a remote install with dependencies, 
because that code (which I created) uses a "gets" from deep within the 
model to confirm that it's OK to install a dependency.  Curt would 
probably prefer a dialog box.  I had a plan to fix it with a kind of 
resumable exception thingy, but I haven't had a lot of time in the past 

> Notice that a *gem*-related exception just gets a brief error message
> by default, but an unexpected error (e.g. NameError) will get the full
> gory details (needed for tracking down the cause).
> I like this approach, but would like to solicit comment.  In
> particular, should we be using the existing variable $VERBOSE or not?

I think it's a great idea, but I don't like the use of $VERBOSE.  I may 
be wrong, though.


More information about the Rubygems-developers mailing list