diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm
index 86a46f693c..01196eb3e4 100644
--- a/guix/scripts/style.scm
+++ b/guix/scripts/style.scm
@@ -392,6 +392,14 @@ doing it."
                              (G_ "would be edited~%")))
                      str)))
 
+(define (absolute-location loc)
+  "Replace the file name in LOC by an absolute location."
+  (location (if (string-prefix? "/" (location-file loc))
+                (location-file loc)
+                (search-path %load-path (location-file loc)))
+            (location-line loc)
+            (location-column loc)))
+
 (define* (simplify-package-inputs package
                                   #:key (policy 'silent)
                                   (edit-expression edit-expression))
@@ -413,7 +421,7 @@ PACKAGE."
                     #f)
                    (location
                     (edit-expression
-                     (location->source-properties location)
+                     (location->source-properties (absolute-location location))
                      (lambda (str)
                        (define matches?
                          (match policy