rustguix

unbound variable when creating a Guix rust package with dependencies


I'm trying to create a guix package for the xsv crate. I use output of guix import crate xsv and add the necessary use-modules lines, which gives the following rust_xsv.scm file :

(use-modules (guix packages)
             (guix download)
             (guix build-system cargo)
             ((guix licenses) #:prefix license:))

;; (define-public rust-xsv-0.13
  (package
    (name "rust-xsv")
    (version "0.13.0")
    (source (origin
              (method url-fetch)
              (uri (crate-uri "xsv" version))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0pvzr7x5phlya6m5yikvy13vgbazshw0plysckz9zmf2ly5x4jl8"))))
    (build-system cargo-build-system)
    (arguments
     `(#:cargo-inputs (("rust-byteorder" ,rust-byteorder-1)
                       ("rust-chan" ,rust-chan-0.1)
                       ("rust-csv" ,rust-csv-1)
                       ("rust-csv-index" ,rust-csv-index-0.1)
                       ("rust-docopt" ,rust-docopt-1)
                       ("rust-filetime" ,rust-filetime-0.1)
                       ("rust-num-cpus" ,rust-num-cpus-1)
                       ("rust-rand" ,rust-rand-0.4)
                       ("rust-regex" ,rust-regex-1)
                       ("rust-serde" ,rust-serde-1)
                       ("rust-serde-derive" ,rust-serde-derive-1)
                       ("rust-streaming-stats" ,rust-streaming-stats-0.2)
                       ("rust-tabwriter" ,rust-tabwriter-1)
                       ("rust-threadpool" ,rust-threadpool-1))
       #:cargo-development-inputs (("rust-log" ,rust-log-0.4)
                                   ("rust-quickcheck" ,rust-quickcheck-0.6))))
    (home-page "https://github.com/BurntSushi/xsv")
    (synopsis "A high performance CSV command line toolkit.")
    (description
     "This package provides a high performance CSV command line toolkit.")
    (license (list license:unlicense license:expat)))
;; )

When I try to build this package with guix package --install-from-file=./rust-xsv.scm I get the error error: rust-byteorder-1: unbound variable, in other words it doesn´t find the cargo-input dependencies. What am I missing ?

Here is the complete trace :

The following package will be installed:
   rust-xsv 0.13.0

Backtrace:
In guix/ui.scm:
   2263:7 19 (run-guix . _)
  2226:10 18 (run-guix-command _ . _)
In ice-9/boot-9.scm:
  1752:10 17 (with-exception-handler _ _ #:unwind? _ # _)
In guix/status.scm:
    835:3 16 (_)
    815:4 15 (call-with-status-report _ _)
In guix/store.scm:
   1298:8 14 (call-with-build-handler #<procedure 7f93512c2b70 at g…> …)
In guix/build/syscalls.scm:
   1428:3 13 (_)
   1395:4 12 (call-with-file-lock/no-wait _ #<procedure 7f934238684…> …)
In guix/scripts/package.scm:
   153:19 11 (build-and-use-profile #<store-connection 256.99 7f935…> …)
In guix/store.scm:
  2168:25 10 (run-with-store #<store-connection 256.99 7f93511bf640> …)
In guix/profiles.scm:
    666:3  9 (_ _)
In srfi/srfi-1.scm:
   586:17  8 (map1 (#<<manifest-entry> name: "rust-xsv" version: …> …))
In guix/profiles.scm:
  1929:19  7 (_ _)
In guix/packages.scm:
  1279:17  6 (supported-package? #<package rust-xsv@0.13.0 /home/he…> …)
In guix/memoization.scm:
    101:0  5 (_ #<hash-table 7f93429e7f00 0/31> #<package rust-xsv@…> …)
In guix/packages.scm:
  1257:37  4 (_)
  1517:16  3 (package->bag _ _ _ #:graft? _)
  1622:43  2 (thunk)
In /home/henri/travaux/www/orchestraGuix/rust-xsv.scm:
    19:42  1 (arguments #<package rust-xsv@0.13.0 /home/henri/travau…>)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
error: rust-byteorder-1: unbound variable

Solution

  • I was missing two things :

    1. an import of the (gnu packages crate-io) in order to have access to the crates already packaged in the guix repository (like rust-byteorder)
    2. the -r option in the initial command guix import crate -r xsv in order to get the definitions of the crates not already packaged by guix repo.

    Here is the fixed file :

    (use-modules (guix packages)
                 (guix download)
                 (guix build-system cargo)
                 (gnu packages crates-io)
                 ((guix licenses) #:prefix license:))
    
    (define-public rust-filetime-0.1
      (package
        (name "rust-filetime")
        (version "0.1.15")
        (source (origin
                  (method url-fetch)
                  (uri (crate-uri "filetime" version))
                  (file-name (string-append name "-" version ".tar.gz"))
                  (sha256
                   (base32
                    "03xishfxzpr4nfz4g3r218d6b6g94rxsqw9pw96m6wa8wgrm6iki"))))
        (build-system cargo-build-system)
        (arguments
         `(#:skip-build? #t
           #:cargo-inputs (("rust-cfg-if" ,rust-cfg-if-0.1)
                           ("rust-libc" ,rust-libc-0.2)
                           ("rust-redox-syscall" ,rust-redox-syscall-0.1))))
        (home-page "https://github.com/alexcrichton/filetime")
        (synopsis "Platform-agnostic accessors of timestamps in File metadata
    ")
        (description "Platform-agnostic accessors of timestamps in File metadata")
        (license (list license:expat license:asl2.0))))
    (define-public rust-csv-index-0.1
      (package
        (name "rust-csv-index")
        (version "0.1.6")
        (source (origin
                  (method url-fetch)
                  (uri (crate-uri "csv-index" version))
                  (file-name (string-append name "-" version ".tar.gz"))
                  (sha256
                   (base32
                    "01048y84y0bakqm0x4y1svjv6lzc753b9q598xp7xgcqrdgi6x7j"))))
        (build-system cargo-build-system)
        (arguments
         `(#:skip-build? #t
           #:cargo-inputs (("rust-byteorder" ,rust-byteorder-1)
                           ("rust-csv" ,rust-csv-1))))
        (home-page "https://github.com/BurntSushi/rust-csv")
        (synopsis "On disk CSV indexing data structures.")
        (description "On disk CSV indexing data structures.")
        (license (list license:unlicense license:expat))))
    
    (define-public rust-chan-0.1
      (package
        (name "rust-chan")
        (version "0.1.23")
        (source (origin
                  (method url-fetch)
                  (uri (crate-uri "chan" version))
                  (file-name (string-append name "-" version ".tar.gz"))
                  (sha256
                   (base32
                    "1n0y992mqfk5zpxzvrv14g9qivacmd4fiv4j1nmgyrg0vaimcjfi"))))
        (build-system cargo-build-system)
        (arguments
         `(#:skip-build? #t
           #:cargo-inputs (("rust-rand" ,rust-rand-0.3))))
        (home-page "https://github.com/BurntSushi/chan")
        (synopsis "DEPRECATED. Use crossbeam-channel instead.")
        (description "DEPRECATED.  Use crossbeam-channel instead.")
        (license (list license:unlicense license:expat))))
    
    ;; (define-public rust-xsv-0.13
      (package
        (name "rust-xsv")
        (version "0.13.0")
        (source (origin
                  (method url-fetch)
                  (uri (crate-uri "xsv" version))
                  (file-name (string-append name "-" version ".tar.gz"))
                  (sha256
                   (base32
                    "0pvzr7x5phlya6m5yikvy13vgbazshw0plysckz9zmf2ly5x4jl8"))))
        (build-system cargo-build-system)
        (arguments
         `(#:cargo-inputs (("rust-byteorder" ,rust-byteorder-1)
                           ("rust-chan" ,rust-chan-0.1)
                           ("rust-csv" ,rust-csv-1)
                           ("rust-csv-index" ,rust-csv-index-0.1)
                           ("rust-docopt" ,rust-docopt-1)
                           ("rust-filetime" ,rust-filetime-0.1)
                           ("rust-num-cpus" ,rust-num-cpus-1)
                           ("rust-rand" ,rust-rand-0.4)
                           ("rust-regex" ,rust-regex-1)
                           ("rust-serde" ,rust-serde-1)
                           ("rust-serde-derive" ,rust-serde-derive-1)
                           ("rust-streaming-stats" ,rust-streaming-stats-0.2)
                           ("rust-tabwriter" ,rust-tabwriter-1)
                           ("rust-threadpool" ,rust-threadpool-1))
           #:cargo-development-inputs (("rust-log" ,rust-log-0.4)
                                       ("rust-quickcheck" ,rust-quickcheck-0.6))))
        (home-page "https://github.com/BurntSushi/xsv")
        (synopsis "A high performance CSV command line toolkit.")
        (description
         "This package provides a high performance CSV command line toolkit.")
        (license (list license:unlicense license:expat)))
    ;; )