utils: 'current-source-directory' gracefully handles lack of source info.
authorLudovic Courtès <ludo@gnu.org>
Sun, 19 Jun 2016 20:30:34 +0000 (22:30 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sun, 19 Jun 2016 22:52:53 +0000 (00:52 +0200)
* guix/utils.scm (current-source-directory): Add case for when FILE-NAME
is #f.

guix/utils.scm

index 0e20be3..69f4e78 100644 (file)
@@ -727,9 +727,12 @@ be determined."
           ;; the absolute file name by looking at %LOAD-PATH; doing this at
           ;; run time rather than expansion time is necessary to allow files
           ;; to be moved on the file system.
-          (if (string-prefix? "/" file-name)
-              (dirname file-name)
-              #`(absolute-dirname #,file-name)))
+          (cond ((not file-name)
+                 #f)                ;raising an error would upset Geiser users
+                ((string-prefix? "/" file-name)
+                 (dirname file-name))
+                (else
+                 #`(absolute-dirname #,file-name))))
          (_
           #f))))))