# Curl/Curb - Adding an on\_debug handler causes an exit code of "1"?

**URL:** <https://www.ruby-forum.com/t/curl-curb-adding-an-on-debug-handler-causes-an-exit-code-of-1/117579>\
**Category:** Ruby\
**Created:** [October 18, 2007, 7:52am UTC](https://www.ruby-forum.com/t/curl-curb-adding-an-on-debug-handler-causes-an-exit-code-of-1/117579 "2007-10-18T07:52:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_Foxworthington](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@Rob\_Foxworthington](https://www.ruby-forum.com/u/Rob_Foxworthington)\
**Post date:** [October 18, 2007, 7:52am UTC](https://www.ruby-forum.com/t/curl-curb-adding-an-on-debug-handler-causes-an-exit-code-of-1/117579/1 "2007-10-18T07:52:45Z")

</div>

Using the very handy Curb from [http://curb.rubyforge.org/](http://curb.rubyforge.org/)…

Maybe I’m doing something wrong, but it seems that the mere presence  
of an on\_debug handler causes the exit code of a script to be “1”  
instead of “0”.

Unfortunately my C skills are non-existent, so I don’t understand  
Curb’s sources. The best I can do is provide this simple test case in  
Ruby:

```
$ cat exit_code.rb
require "curl"
curl = Curl::Easy.new "http://www.google.com/"
curl.perform

$ ruby exit_code.rb ; echo $?
0

$ cat exit_code_on_debug.rb
require "curl"
curl = Curl::Easy.new "http://www.google.com/"
curl.on_debug { |type, data| true }
curl.perform

$ ruby exit_code_on_debug.rb ; echo $?
1

```

Using Curb 0.1.4, tried the above on Mac OS X 10.4 (ruby 1.8.6, curl  
7.17.0) and CentOS 5 (ruby 1.8.5, curl 7.15.5)… same results.

Any hints, workaround, etc very much appreciated. – Thanks!

Background: I have some Rake tasks that call code involving Curl/Curb  
with an on\_debug handler attached (used to capture “Cookie:” headers  
added by libcurl’s cookie engine). After the Curl/Curb stuff is  
called, the exit code is “1” and Rake aborts, preventing follow-up  
tasks from running.

---

<div class="post-metadata">

**Author:** ![Rob\_Foxworthington](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@Rob\_Foxworthington](https://www.ruby-forum.com/u/Rob_Foxworthington)\
**Post date:** [November 11, 2007, 7:39pm UTC](https://www.ruby-forum.com/t/curl-curb-adding-an-on-debug-handler-causes-an-exit-code-of-1/117579/2 "2007-11-11T19:39:25Z")

</div>

Follow-up: Upgrading to Ruby 1.8.6p110 seems to fix the problem.
