Hi,

Some of us are not always happy with the Guix/Guile error reporting.  As
discussed at the Guix Days, maybe the best strategy to improve the
situation is to report small examples that we can work on.  Therefore,
here one that I have just hit today when working on Julia.

Here a minimalist example.

--8<---------------cut here---------------start------------->8---
$ guix build -L foo git2cl-bang
Backtrace:
In guix/gexp.scm:
   1218:2 19 (_ #<store-connection 256.100 7fa4a8355eb0>)
   1085:2 18 (_ _)
    926:4 17 (_ _)
In guix/store.scm:
  2095:12 16 (_ #<store-connection 256.100 7fa4a8355eb0>)
  1412:11 15 (map/accumulate-builds #<store-connection 256.100 7fa4a8355eb0> 
#<procedure 7fa4a835cfc0 at guix/store.scm:2096:35 (obj)> _ #:cutoff _)
   1330:8 14 (call-with-build-handler #<procedure 7fa4a835cf90 at 
guix/store.scm:1365:2 (continue store things mode)> _)
  2210:25 13 (run-with-store #<store-connection 256.100 7fa4a8355eb0> 
#<procedure 7fa4aa99c840 at guix/gexp.scm:931:13 (state)> #:guile-for-build _ # 
_ # _)
In guix/gexp.scm:
   931:13 12 (_ _)
In guix/store.scm:
   2038:8 11 (_ _)
In guix/gexp.scm:
   300:22 10 (_ _)
In guix/store.scm:
  2142:12  9 (_ #<store-connection 256.100 7fa4a8355eb0>)
  1173:24  8 (_ #<store-connection 256.100 7fa4a8355eb0> "git2cl" #t "sha256" 
"/tmp/git2cl" #:select? _)
  1151:14  7 (add-to-store #<store-connection 256.100 7fa4a8355eb0> _ _ 
"sha256" "/tmp/git2cl" #:select? _)
In guix/serialization.scm:
   380:43  6 (dump "/tmp/git2cl")
In srfi/srfi-1.scm:
   691:23  5 (filter-map #<procedure 7fa4aa99c2c0 at 
guix/serialization.scm:322:33 (base)> ("COPYING" "README" "README.html" 
"git2cl") . _)
In guix/serialization.scm:
   325:42  4 (_ "COPYING")
   325:42  3 (_ "/tmp/git2cl/COPYING")
In ice-9/boot-9.scm:
  1685:16  2 (raise-exception _ #:continuable? _)
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Wrong type to apply: #f
--8<---------------cut here---------------end--------------->8---

Good luck to guess what’s wrong. :-)

The package definition:

--8<---------------cut here---------------start------------->8---
(define-module (bar)
  #:use-module (guix)
  #:use-module (gnu)
  #:use-module (guix build-system copy)
  #:use-module ((guix git-download) #:select (git-predicate))
  #:use-module (gnu packages version-control))

(define-public git2cl-local-file
  (package
    (inherit git2cl)
    (name "git2cl-bang")
    (source
     (local-file "/tmp/git2cl"
                 #:recursive? #t
                 #:select? (git-predicate "/tmp/git2cl")
                 ))))
--8<---------------cut here---------------end--------------->8---

where /tmp/git2cl is populated with:

        cp -r $(guix build git2cl -S) /tmp/git2cl

And note that the initial origin is from a Git repository, it reads:

      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://git.savannah.nongnu.org/git/git2cl.git";)
                      (commit commit)))
                (file-name (git-file-name name version))
                (sha256
                 (base32
                  "0wnnbm2sjvfj0qrksj89jlnl69miwl0vk3wrrvgvpclgys3na2g1"))))


As always, once you get it, aaaahhh it’s obvious… But Guix has not
really helped me in finding what was wrong. :-) I found my way with good
ol’ grep in Guix source code and/or gave a look to (guix gexp); Then I
had my aaaahhh moment.

The mistake is obviously that ’git-predicate’ always returns #f because
/tmp/git2cl is not a Git repository.

Hum, I’m not sure to understand well enough how ’local-file’ internally
works to propose an improvement (handle the exception).

Somehow, I do not know if it’s low-hanging fruit but a better error
reporting for this kind of “simple” mistake would improvement a lot the
user experience, IMHO.

Ah, Julia is compiled now… back to work. ;-)

Cheers,
simon

Reply via email to