Subject: (current-filename) is #f when guix pull'ing

From: Attila Lendvai <[email-masked]>
Date: Mon, 16 May 2022 21:04:10 +0000

the actual context where i'm encountering this is a package definition where i want to load some hashes from a file relative the to the .scm file:

(define-public foo
  (let ((hashes
    (with-input-from-file
        (string-append (dirname (current-filename))
                       "/foo.hashes")
      read)))
    (package ...)))

this works fine in a `./pre-inst-env build foo`, but i think there's something special in how `guix pull` compiles the scm files, and (c-f) expands to #f. guix pull works, but afterwards:

$ guix system --on-error=backtrace reconfigure --allow-downgrades /etc/guix/config.scm
guix system: error: failed to load '/etc/guix/config.scm':
guix-crypto/packages/ethereum.scm:47:36: In procedure scm_to_utf8_stringn: Wrong type argument in position 1 (expecting string): #f

In ice-9/boot-9.scm:
   222:29 19 (map1 (((gnu)) ((gnu system)) ((gnu system #)) ((# …)) …))
   222:29 18 (map1 (((gnu system)) ((gnu system file-systems)) (#) …))
   222:29 17 (map1 (((gnu system file-systems)) ((oop goops)) ((…)) …))
   222:29 16 (map1 (((oop goops)) ((shepherd service)) ((nongnu …)) …))
   222:29 15 (map1 (((shepherd service)) ((nongnu packages linux)) …))
   222:29 14 (map1 (((nongnu packages linux)) ((guix-crypto # #)) # …))
   222:17 13 (map1 (((guix-crypto packages ethereum)) ((# # #)) (#) …))
  3936:31 12 (_ ((guix-crypto packages ethereum)))
  3327:17 11 (resolve-interface (guix-crypto packages ethereum) # _ # …)
In ice-9/threads.scm:
    390:8 10 (_ _)
In ice-9/boot-9.scm:
  3253:13  9 (_)
In ice-9/threads.scm:
    390:8  8 (_ _)
In ice-9/boot-9.scm:
  3544:20  7 (_)
   2836:4  6 (save-module-excursion #<procedure 7f056144d810 at ice-…>)
  3564:26  5 (_)
In unknown file:
           4 (primitive-load-path "guix-crypto/packages/ethereum" #<…>)
In guix-crypto/packages/ethereum.scm:
    47:36  3 (_)
In unknown file:
           2 (dirname #f)
In ice-9/boot-9.scm:
  1685:16  1 (raise-exception _ #:continuable? _)
  1780:13  0 (_ #<&compound-exception components: (#<&assertion-fail…>)

i would be happy to avoid using (c-f), but i failed to find a way in Guile's module reflection API.

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“People who have never gone to school have never developed negative attitudes toward exploring their world.”
	— Grace Llewellyn