utils: 'cache-directory' gracefully deals with unset 'HOME'.

Fixes <http://bugs.gnu.org/23165>.

* guix/utils.scm (cache-directory): Use 'getpwuid' when 'HOME' is unset.
This commit is contained in:
Ludovic Courtès 2016-04-18 19:26:34 +02:00
parent cd76fbde6f
commit dd1d09f7e4
1 changed files with 2 additions and 1 deletions

View File

@ -808,7 +808,8 @@ elements after E."
(define (cache-directory) (define (cache-directory)
"Return the cache directory for Guix, by default ~/.cache/guix." "Return the cache directory for Guix, by default ~/.cache/guix."
(or (getenv "XDG_CONFIG_HOME") (or (getenv "XDG_CONFIG_HOME")
(and=> (getenv "HOME") (and=> (or (getenv "HOME")
(passwd:dir (getpwuid (getuid))))
(cut string-append <> "/.cache/guix")))) (cut string-append <> "/.cache/guix"))))
(define (readlink* file) (define (readlink* file)