Subject: Re: bug#43818: Use of local-file in icecat-source definition breaks REPL
From: Maxim Cournoyer <[email-masked]>
To: [email-masked]
Cc: "Mark H. Weaver" <[email-masked]>, Christopher Baines <[email-masked]>
Date: Sat, 24 Oct 2020 00:55:16 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

Maxim Cournoyer <[email-masked]> writes:

> CC: Mark H Weaver, one of the Icecat maintainer.
>
> Hello,
>
> The problem is that local-file doesn't work in Geiser.  This breaks
> working at the REPL:
>
> Enter `,help' for help.
> scheme@(guile-user)> ,m (gnu packages linux)
> While executing meta-command:
> ERROR:
>   1. &formatted-message:
>       format: "~a: patch not found\n"
>       arguments: ("icecat-use-older-reveal-hidden-html.patch")

Thanks for Christopher Baines on #guix who pointed that local-file
seemed to behave correctly at the REPL and Geiser (indeed!).  It made me
try to reproduce it in a --pure environment and I couldn't.

After a couple hours digging, I found that this snippet in my modified
.dir-locals file:

--8<---------------cut here---------------start------------->8---
(with-eval-after-load 'geiser-guile
  (let ((root-dir (locate-dominating-file
                   default-directory ".dir-locals.el")))
    (setq geiser-guile-load-path
          (cons root-dir
                (delete root-dir geiser-guile-load-path)))))
--8<---------------cut here---------------end--------------->8---

Was the culprit, especially the use of with-eval-after-load (which
turned out to be unnecessary).

This snippet allows to switch between git worktrees and always have the
geiser-guile-load-path (which configures both the Guile %load-path and
the %load-compiled-path) set correctly.

Here's the diff of my (fixed) .dir-locals in my Guix git checkout:

--8<---------------cut here---------------start------------->8---
~/src/guix$ git diff .dir-locals.el
diff --git a/.dir-locals.el b/.dir-locals.el
index 19f15b3e1a..0869fbaa20 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -8,7 +8,17 @@
      ;; For use with 'bug-reference-prog-mode'.
      (bug-reference-url-format . "http://bugs.gnu.org/%s")
      (bug-reference-bug-regexp
-      . "<https?://\\(debbugs\\|bugs\\)\\.gnu\\.org/\\([0-9]+\\)>")))
+      . "<https?://\\(debbugs\\|bugs\\)\\.gnu\\.org/\\([0-9]+\\)>")
+
+     ;; Emacs-Guix
+     (eval . (setq guix-directory
+                   (locate-dominating-file default-directory ".dir-locals.el")))
+     ;; Geiser
+     (eval . (let ((root-dir (locate-dominating-file
+                              default-directory ".dir-locals.el")))
+               (setq geiser-guile-load-path
+                     (cons root-dir
+                           (delete root-dir geiser-guile-load-path)))))))
  (c-mode          . ((c-file-style . "gnu")))
  (scheme-mode
   .
--8<---------------cut here---------------end--------------->8---

I am closing this issue, sorry for the noise!

Maxim