darcs

Issue 858 Darcs doesn't return a proper exit code on errors

Title Darcs doesn't return a proper exit code on errors
Priority not-our-bug Status wont-fix
Milestone Resolved in
Superseder Nosy List darcs-devel, dmitry.kurochkin, gwern, kowey, thorkilnaur, tommy
Assigned To
Topics HTTP

Created on 2008-05-16.18:01:16 by gwern, last changed 2009-09-04.09:46:34 by kowey.

Files
File name Uploaded Type Edit Remove
unnamed dagit, 2008-05-16.18:20:38 text/html
Messages
msg4726 (view) Author: gwern Date: 2008-05-16.18:01:14
So I recently was trying to download the announced ChessLibrary library from
http://code.haskell.org/ChessLibrary . Alas, each and every Darcs get failed. I
verified I could access it at all by visiting it in a browser, but the gets kept
failing.

How irksome! Perhaps there was some transient network problem that would go away
with sufficient brute force. So I did a basic shell script:

 while true; do get http://code.haskell.org/ChessLibrary/ && break; done

(The idea is, if Darcs ever succeeds, we break out of the infinite loop.)

Imagine my surprise when the loop ran exactly once, but I had no useable
ChessLibrary directory.

Why? Well:

gwern@localhost:5238~/bin/darcs/darcs.net>darcs get
http://code.haskell.org/ChessLibrary/ && echo foo                              
[ 1:58PM]
Directory '/home/gwern/bin/darcs/darcs.net/ChessLibrary' already exists,
creating repository as '/home/gwern/bin/darcs/darcs.net/ChessLibrary_1'

darcs failed:  Not a repository: http://code.haskell.org/ChessLibrary (Failed to
download URL http://code.haskell.org/ChessLibrary/_darcs/inventory: HTTP
response code said error)
foo


So in other words, Darcs was claiming success even in the face of utter failure.
Much as I admire such indomitable willpower and optimism, it gets in the way. :)

I went code hunting, and I found that withSignalsHandled was doing the right
thing, it was setting an ExitStatus of Failure. So Darcs should've been exiting
the right way. But it seems that in darcs.lhs, withSignalsHandled is passed on
to with_atexit in Global.hs. And with_atexit throws away the information: it
returns successfully - after doing some printing to stderr.

I edited it lightly to guarantee an erroneous exit status:

gwern@localhost:5239~/bin/darcs/darcs.net>new                                  
                                                    [ 1:58PM]
hunk ./src/Darcs/Global.lhs 70               
-            hPutStrLn stderr $ "Exception thrown by an atexit registered action:"
-            hPutStrLn stderr $ show exn
+           hPutStrLn stderr $ "Exception thrown by an atexit registered action:"
+           error $ show exn

And I tried with those changes:

gwern@localhost:5236~/bin/darcs/darcs.net>./darcs get
http://code.haskell.org/ChessLibrary/ && echo foo                             [
2:04PM]
Directory '/home/gwern/bin/darcs/darcs.net/ChessLibrary' already exists,
creating repository as '/home/gwern/bin/darcs/darcs.net/ChessLibrary_2'
                                                                     
darcs failed:  Not a repository: http://code.haskell.org/ChessLibrary (Failed to
download URL http://code.haskell.org/ChessLibrary/_darcs/inventory: HTTP
response code said error)

Much better.

Oddly, this seems to cause test problems (otherwise I'd record and send):

TESTS FAILED!
	whatsnew.sh
	either_dependency.sh

Do these tests depend on Darcs always succeeding, or were some regressions
introduced when I wasn't looking?
msg4727 (view) Author: dagit Date: 2008-05-16.18:20:38
On Fri, May 16, 2008 at 11:01 AM, gwern <bugs@darcs.net> wrote:

>
>
> Oddly, this seems to cause test problems (otherwise I'd record and send):
>
> TESTS FAILED!
>        whatsnew.sh
>        either_dependency.sh
>
> Do these tests depend on Darcs always succeeding, or were some regressions
> introduced when I wasn't looking?

Thanks for the bug report and the research.  There have been discussions in
the past about what darcs means when it returns success or failure:
http://lists.osuosl.org/pipermail/darcs-devel/2006-September/004789.html

The other one I can't find right now, but it was to the effect, what should
darcs return when a pre or post hook fails?  I don't recall what we decided
to do now, but if I recall correctly you can look in Test.lhs and find the
code.

Whatever solution you take here should respect the decisions made in the
past, but I'm not much help beyond that.  I would agree that the behavior
you see in the retry script is wrong.

Jason
Attachments
msg4729 (view) Author: droundy Date: 2008-05-16.18:27:33
> Oddly, this seems to cause test problems (otherwise I'd record and send):
>
> TESTS FAILED!
> 	whatsnew.sh
> 	either_dependency.sh
>
> Do these tests depend on Darcs always succeeding, or were some regressions
> introduced when I wasn't looking?

These tests aren't causing darcs record to fail, as their in the bugs/
directory.  It just looks like their failing, because they're known bugs.

David
msg4739 (view) Author: droundy Date: 2008-05-17.12:09:26
I'm not able to reproduce this bug.
msg4807 (view) Author: kowey Date: 2008-05-21.10:38:52
Gwern: if you have not done so already, could you submit a darcs patch?  I don't
see it in darcs changes, nor in my mail archives.
msg4852 (view) Author: gwern Date: 2008-05-23.17:19:53
I've since been doing some testing with my patch, and I think I may have messed
up in filing this - I'm now fairly sure that the behavior I was seeing stemmed
from some shell scripts and options. (I'm not entirely sure why yet, but
avoiding the shell seems to resolve the problem.)
msg8674 (view) Author: kowey Date: 2009-09-04.09:00:28
Hi Gwern,

Just to make sure: do you now think this is not-our-bug?  Could you clarify? 
Thanks!
msg8678 (view) Author: gwern Date: 2009-09-04.09:29:20
> Just to make sure: do you now think this is not-our-bug?  Could you clarify? 

Yes; I forget exactly what the problem was - I think it was a semicolon in my
darcs-wrapper function. But my current darcs seems to error out correctly on
non-existent repos.
msg8682 (view) Author: kowey Date: 2009-09-04.09:46:32
Thanks!  wont-fixing accordingly.
History
Date User Action Args
2008-05-16 18:01:16gwerncreate
2008-05-16 18:20:41dagitsetfiles: + unnamed
nosy: tommy, beschmi, dagit, gwern
status: unread -> unknown
messages: + msg4727
2008-05-16 18:27:35droundysetnosy: + droundy
messages: + msg4729
2008-05-17 12:09:28droundysetstatus: unknown -> waiting-for
nosy: droundy, tommy, beschmi, dagit, gwern
messages: + msg4739
2008-05-21 10:38:53koweysetstatus: waiting-for -> has-patch
nosy: + kowey
messages: + msg4807
assignedto: gwern
2008-05-23 17:19:55gwernsetnosy: droundy, tommy, beschmi, kowey, dagit, gwern
messages: + msg4852
2009-08-06 17:58:37adminsetnosy: + markstos, jast, Serware, dmitry.kurochkin, darcs-devel, zooko, mornfall, simon, thorkilnaur, - droundy, gwern
2009-08-06 21:05:00adminsetnosy: - beschmi
2009-08-10 22:20:39adminsetnosy: + gwern, - markstos, darcs-devel, zooko, jast, Serware, mornfall
2009-08-11 00:14:18adminsetnosy: - dagit
2009-08-25 18:08:45adminsetnosy: + darcs-devel, - simon
2009-08-27 13:59:52adminsetnosy: tommy, kowey, darcs-devel, thorkilnaur, gwern, dmitry.kurochkin
2009-09-04 09:00:32koweysetstatus: has-patch -> waiting-for
nosy: tommy, kowey, darcs-devel, thorkilnaur, gwern, dmitry.kurochkin
topic: + HTTP
messages: + msg8674
2009-09-04 09:29:25gwernsetnosy: tommy, kowey, darcs-devel, thorkilnaur, gwern, dmitry.kurochkin
messages: + msg8678
2009-09-04 09:46:34koweysetpriority: bug -> not-our-bug
status: waiting-for -> wont-fix
assignedto: gwern ->
messages: + msg8682
nosy: tommy, kowey, darcs-devel, thorkilnaur, gwern, dmitry.kurochkin