From 9a38bed2cf32e9462badfa43e74cdd4580e804fc Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 22 Feb 2021 10:52:21 +0100 Subject: packages: 'package-field-location' handles 'search-path' returning #f. Fixes . Reported by zimoun . This is similar to the fix in d10474c38d58bdc676e64336769dc2e00cdfa8ed. * guix/packages.scm (package-field-location): Handle FILE not in %LOAD-PATH. * tests/guix-lint.sh: Add test. --- guix/packages.scm | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'guix/packages.scm') diff --git a/guix/packages.scm b/guix/packages.scm index 9305dabcec..57bc148002 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -475,29 +475,34 @@ (define (goto port line column) (match (package-location package) (($ file line column) - (catch 'system-error - (lambda () - ;; In general we want to keep relative file names for modules. - (call-with-input-file (search-path %load-path file) - (lambda (port) - (goto port line column) - (match (read port) - (('package inits ...) - (let ((field (assoc field inits))) - (match field - ((_ value) - (let ((loc (and=> (source-properties value) - source-properties->location))) - (and loc - ;; Preserve the original file name, which may be a - ;; relative file name. - (set-field loc (location-file) file)))) - (_ - #f)))) - (_ - #f))))) - (lambda _ - #f))) + (match (search-path %load-path file) + ((? string? file) + (catch 'system-error + (lambda () + ;; In general we want to keep relative file names for modules. + (call-with-input-file file + (lambda (port) + (goto port line column) + (match (read port) + (('package inits ...) + (let ((field (assoc field inits))) + (match field + ((_ value) + (let ((loc (and=> (source-properties value) + source-properties->location))) + (and loc + ;; Preserve the original file name, which may be a + ;; relative file name. + (set-field loc (location-file) file)))) + (_ + #f)))) + (_ + #f))))) + (lambda _ + #f))) + (#f + ;; FILE could not be found in %LOAD-PATH. + #f))) (_ #f))) -- cgit v1.2.3