[PATCH] profiles: emacs-subdirs: Avoid building list with a loop

  • Open
  • quality assurance status badge
Details
5 participants
  • Andres Moreno
  • Thiago Jung Bauermann
  • Liliana Marie Prikler
  • Ludovic Courtès
  • Navajeeth
Owner
unassigned
Submitted by
Thiago Jung Bauermann
Severity
normal
T
T
Thiago Jung Bauermann wrote 7 days ago
(address . guix-patches@gnu.org)
20250124230226.107387-1-bauermann@kolabnow.com
If the EMACSNATIVELOADPATH environment variable (by mistake) has duplicated
paths, Emacs fails to load with:

$ emacs
List contains a loop:
("/home/user/.guix-profile/lib/emacs/native-site-lisp"
"/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp"
"/home/user/.guix-profile/lib/emacs/native-site-lisp"
"/home/user/.guix-profile/lib/emacs/native-site-lisp"
"/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp" . #2)
$ echo $?
255

A git bisect in Guix to find when the problem was introduced arrived at
commit e9b13294700d ("profiles: emacs-subdirs: Also expand
native-comp-eln-load-path.").

Fix the problem by applying Liliana's suggestion of changing 'nconc' to
'append' in the Elisp code written to subdirs.el.

* guix/profiles.scm (emacs-subdirs): Use 'append' rather than 'nconc'.

Change-Id: If646b806f24666b5247850d30d2819c7482c130b
Suggested-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
---
guix/profiles.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Toggle diff (15 lines)
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 87b9543ac01f..63b2a08a48d4 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1230,8 +1230,8 @@ (define build
(setq native-comp-eln-load-path
(mapcan (lambda (dir)
(if (equal dir needle)
- (nconc ',native-comp-dirs
- (list dir))
+ (append ',native-comp-dirs
+ (list dir))
(list dir)))
native-comp-eln-load-path))))
port)
L
L
Liliana Marie Prikler wrote 7 days ago
bf38579037ec2abaddcc2ffe60b1aa3377d6415c.camel@gmail.com
Am Freitag, dem 24.01.2025 um 20:01 -0300 schrieb Thiago Jung
Bauermann:
Toggle quote (20 lines)
> If the EMACSNATIVELOADPATH environment variable (by mistake) has
> duplicated paths, Emacs fails to load with:
>
>   $ emacs
>   List contains a loop:
>   ("/home/user/.guix-profile/lib/emacs/native-site-lisp"
>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp"
>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp" .
> #2)
>   $ echo $?
>   255
>
> A git bisect in Guix to find when the problem was introduced arrived
> at commit e9b13294700d ("profiles: emacs-subdirs: Also expand
> native-comp-eln-load-path.").
>
> Fix the problem by applying Liliana's suggestion of changing 'nconc'
> to 'append' in the Elisp code written to subdirs.el.
It's better to describe the bug in code so that folks won't stumble
over it again. E.g. "Note: needle may be found multiple times, so
don't use destructive procedures like nconc."
Toggle quote (5 lines)
> * guix/profiles.scm (emacs-subdirs): Use 'append' rather than
> 'nconc'.
>
> Change-Id: If646b806f24666b5247850d30d2819c7482c130b
> Fixes: <https://issues.guix.gnu.org/75709>
You have some horizontal space here to name the bug :)
Toggle quote (23 lines)
> Suggested-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
> ---
>  guix/profiles.scm | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/guix/profiles.scm b/guix/profiles.scm
> index 87b9543ac01f..63b2a08a48d4 100644
> --- a/guix/profiles.scm
> +++ b/guix/profiles.scm
> @@ -1230,8 +1230,8 @@ (define build
>                          (setq native-comp-eln-load-path
>                                (mapcan (lambda (dir)
>                                          (if (equal dir needle)
> -                                            (nconc ',native-comp-
> dirs
> -                                                   (list dir))
> +                                            (append ',native-comp-
> dirs
> +                                                    (list dir))
>                                              (list dir)))
>                                        native-comp-eln-load-path))))
>                     port)

Cheers
T
T
Thiago Jung Bauermann wrote 6 days ago
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)(address . 75817@debbugs.gnu.org)
864j1ncyu7.fsf@kolabnow.com
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (26 lines)
> Am Freitag, dem 24.01.2025 um 20:01 -0300 schrieb Thiago Jung
> Bauermann:
>> If the EMACSNATIVELOADPATH environment variable (by mistake) has
>> duplicated paths, Emacs fails to load with:
>>
>>   $ emacs
>>   List contains a loop:
>>   ("/home/user/.guix-profile/lib/emacs/native-site-lisp"
>>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp"
>>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp" .
>> #2)
>>   $ echo $?
>>   255
>>
>> A git bisect in Guix to find when the problem was introduced arrived
>> at commit e9b13294700d ("profiles: emacs-subdirs: Also expand
>> native-comp-eln-load-path.").
>>
>> Fix the problem by applying Liliana's suggestion of changing 'nconc'
>> to 'append' in the Elisp code written to subdirs.el.
> It's better to describe the bug in code so that folks won't stumble
> over it again. E.g. "Note: needle may be found multiple times, so
> don't use destructive procedures like nconc."

Good point. I added your suggested note as a comment in the Elisp code.

Toggle quote (7 lines)
>> * guix/profiles.scm (emacs-subdirs): Use 'append' rather than
>> 'nconc'.
>>
>> Change-Id: If646b806f24666b5247850d30d2819c7482c130b
>> Fixes: <https://issues.guix.gnu.org/75709>
> You have some horizontal space here to name the bug :)

Indeed. I added a short description.

Thank you for your quick review!
--
Thiago
T
T
Thiago Jung Bauermann wrote 6 days ago
[PATCH v2] profiles: emacs-subdirs: Avoid building list with a loop
(address . 75817@debbugs.gnu.org)
20250125041742.168342-1-bauermann@kolabnow.com
If the EMACSNATIVELOADPATH environment variable (by mistake) has duplicated
paths, Emacs fails to load with:

$ emacs
List contains a loop:
("/home/user/.guix-profile/lib/emacs/native-site-lisp"
"/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp"
"/home/user/.guix-profile/lib/emacs/native-site-lisp"
"/home/user/.guix-profile/lib/emacs/native-site-lisp"
"/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp" . #2)
$ echo $?
255

A git bisect in Guix to find when the problem was introduced arrived at
commit e9b13294700d ("profiles: emacs-subdirs: Also expand
native-comp-eln-load-path.").

Fix the problem by applying Liliana's suggestion of changing 'nconc' to
'append' in the Elisp code written to subdirs.el.

* guix/profiles.scm (emacs-subdirs): Use 'append' rather than 'nconc'.

Change-Id: If646b806f24666b5247850d30d2819c7482c130b
Fixes: Emacs "List contains a loop" error https://issues.guix.gnu.org/75709
Suggested-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
---
guix/profiles.scm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

Changes since v1:
Made the following changes suggested by Liliana:
- Added comment to Elisp comment warning about destructive procedures
- Added short bug description to "Fixes" tag.

Toggle diff (19 lines)
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 87b9543ac01f..fb4dbc5bd079 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1230,8 +1230,12 @@ (define build
(setq native-comp-eln-load-path
(mapcan (lambda (dir)
(if (equal dir needle)
- (nconc ',native-comp-dirs
- (list dir))
+ ;; Note: needle may be found
+ ;; multiple times, so don't use
+ ;; destructive procedures like
+ ;; nconc.
+ (append ',native-comp-dirs
+ (list dir))
(list dir)))
native-comp-eln-load-path))))
port)
L
L
Liliana Marie Prikler wrote 6 days ago
a667a2d1fe5ef63598de0e3cb65eaf6df4da1c46.camel@gmail.com
Am Samstag, dem 25.01.2025 um 01:14 -0300 schrieb Thiago Jung
Bauermann:
Toggle quote (30 lines)
> If the EMACSNATIVELOADPATH environment variable (by mistake) has
> duplicated
> paths, Emacs fails to load with:
>
>   $ emacs
>   List contains a loop:
>   ("/home/user/.guix-profile/lib/emacs/native-site-lisp"
>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp"
>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp" .
> #2)
>   $ echo $?
>   255
>
> A git bisect in Guix to find when the problem was introduced arrived
> at commit e9b13294700d ("profiles: emacs-subdirs: Also expand
> native-comp-eln-load-path.").
>
> Fix the problem by applying Liliana's suggestion of changing 'nconc'
> to 'append' in the Elisp code written to subdirs.el.
>
> * guix/profiles.scm (emacs-subdirs): Use 'append' rather than
> 'nconc'.
>
> Change-Id: If646b806f24666b5247850d30d2819c7482c130b
> Fixes: Emacs "List contains a loop" error
> <https://issues.guix.gnu.org/75709>
> Suggested-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
> ---
Reworded commit message slightly and pushed to emacs-team. Let's wait
a little for all Emacsen to rebuild on CI before merging this into
master :)

Thanks
T
T
Thiago Jung Bauermann wrote 5 days ago
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)(address . 75817@debbugs.gnu.org)
86tt9l78pn.fsf@kolabnow.com
Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

Toggle quote (38 lines)
> Am Samstag, dem 25.01.2025 um 01:14 -0300 schrieb Thiago Jung
> Bauermann:
>> If the EMACSNATIVELOADPATH environment variable (by mistake) has
>> duplicated
>> paths, Emacs fails to load with:
>>
>>   $ emacs
>>   List contains a loop:
>>   ("/home/user/.guix-profile/lib/emacs/native-site-lisp"
>>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp"
>>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp" .
>> #2)
>>   $ echo $?
>>   255
>>
>> A git bisect in Guix to find when the problem was introduced arrived
>> at commit e9b13294700d ("profiles: emacs-subdirs: Also expand
>> native-comp-eln-load-path.").
>>
>> Fix the problem by applying Liliana's suggestion of changing 'nconc'
>> to 'append' in the Elisp code written to subdirs.el.
>>
>> * guix/profiles.scm (emacs-subdirs): Use 'append' rather than
>> 'nconc'.
>>
>> Change-Id: If646b806f24666b5247850d30d2819c7482c130b
>> Fixes: Emacs "List contains a loop" error
>> <https://issues.guix.gnu.org/75709>
>> Suggested-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
>> ---
> Reworded commit message slightly and pushed to emacs-team. Let's wait
> a little for all Emacsen to rebuild on CI before merging this into
> master :)
>
> Thanks

Thank you!

--
Thiago
L
L
Ludovic Courtès wrote 4 days ago
Re: [bug#75817] [PATCH v2] profiles: emacs-subdirs: Avoid building list with a loop
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
87ed0ops2k.fsf@gnu.org
Hello,

Liliana Marie Prikler <liliana.prikler@gmail.com> skribis:

Toggle quote (36 lines)
> Am Samstag, dem 25.01.2025 um 01:14 -0300 schrieb Thiago Jung
> Bauermann:
>> If the EMACSNATIVELOADPATH environment variable (by mistake) has
>> duplicated
>> paths, Emacs fails to load with:
>>
>>   $ emacs
>>   List contains a loop:
>>   ("/home/user/.guix-profile/lib/emacs/native-site-lisp"
>>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp"
>>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>>    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
>>    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp" .
>> #2)
>>   $ echo $?
>>   255
>>
>> A git bisect in Guix to find when the problem was introduced arrived
>> at commit e9b13294700d ("profiles: emacs-subdirs: Also expand
>> native-comp-eln-load-path.").
>>
>> Fix the problem by applying Liliana's suggestion of changing 'nconc'
>> to 'append' in the Elisp code written to subdirs.el.
>>
>> * guix/profiles.scm (emacs-subdirs): Use 'append' rather than
>> 'nconc'.
>>
>> Change-Id: If646b806f24666b5247850d30d2819c7482c130b
>> Fixes: Emacs "List contains a loop" error
>> <https://issues.guix.gnu.org/75709>
>> Suggested-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
>> ---
> Reworded commit message slightly and pushed to emacs-team. Let's wait
> a little for all Emacsen to rebuild on CI before merging this into
> master :)

Looking forward to applying this fix (exwm wouldn’t start this morning).
:-)

Ludo’.
L
L
Liliana Marie Prikler wrote 4 days ago
(name . Ludovic Courtès)(address . ludo@gnu.org)
eca1505927eafcd1cecbfcf2a6300bd48ad744bc.camel@gmail.com
Am Montag, dem 27.01.2025 um 09:41 +0100 schrieb Ludovic Courtès:
Toggle quote (46 lines)
> Hello,
>
> Liliana Marie Prikler <liliana.prikler@gmail.com> skribis:
>
> > Am Samstag, dem 25.01.2025 um 01:14 -0300 schrieb Thiago Jung
> > Bauermann:
> > > If the EMACSNATIVELOADPATH environment variable (by mistake) has
> > > duplicated
> > > paths, Emacs fails to load with:
> > >
> > >   $ emacs
> > >   List contains a loop:
> > >   ("/home/user/.guix-profile/lib/emacs/native-site-lisp"
> > >    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp"
> > >    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
> > >    "/home/user/.guix-profile/lib/emacs/native-site-lisp"
> > >    "/gnu/store/…-emacs-lsp-mode-9.0.0/lib/emacs/native-site-lisp"
> > > .
> > > #2)
> > >   $ echo $?
> > >   255
> > >
> > > A git bisect in Guix to find when the problem was introduced
> > > arrived
> > > at commit e9b13294700d ("profiles: emacs-subdirs: Also expand
> > > native-comp-eln-load-path.").
> > >
> > > Fix the problem by applying Liliana's suggestion of changing
> > > 'nconc'
> > > to 'append' in the Elisp code written to subdirs.el.
> > >
> > > * guix/profiles.scm (emacs-subdirs): Use 'append' rather than
> > > 'nconc'.
> > >
> > > Change-Id: If646b806f24666b5247850d30d2819c7482c130b
> > > Fixes: Emacs "List contains a loop" error
> > > <https://issues.guix.gnu.org/75709>
> > > Suggested-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
> > > ---
> > Reworded commit message slightly and pushed to emacs-team.  Let's
> > wait a little for all Emacsen to rebuild on CI before merging this
> > into master :)
>
> Looking forward to applying this fix (exwm wouldn’t start this
> morning).
> :-)
Welp, I just found out the hard way there is no jobset for emacs-team…
Should we add one or just directly push to master?

Cheers
L
L
Ludovic Courtès wrote 4 days ago
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
874j1jho2m.fsf@gnu.org
Hello,

Liliana Marie Prikler <liliana.prikler@gmail.com> skribis:

Toggle quote (6 lines)
>> Looking forward to applying this fix (exwm wouldn’t start this
>> morning).
>> :-)
> Welp, I just found out the hard way there is no jobset for emacs-team…
> Should we add one or just directly push to master?

There was one but it was deactivated; I’ve now reactivated it.


Ludo’.
N
N
Navajeeth wrote 3 days ago
(No Subject)
(name . 75817@debbugs.gnu.org)(address . 75817@debbugs.gnu.org)
gA7NJ_xgN_jkVRaogISWC_VyoM7RIEjotdzrKOE-MYfVa1Bd99OD8lGoREJN-mM651Bi2M9fZBycMj-rYoFQEHnKiMfcGtM87pE2VZh0ou0=@proton.me
How would I apply this patch? Like so?

guix build guix --with-patch=guix=guix.patch

My EXWM, too, wouldn’t start this morning and I am desperate.

—Navajeeth
Attachment: file
A
A
Andres Moreno wrote 2 days ago
EXWM not starting
(address . 75817@debbugs.gnu.org)
CAOXoXz2tL=dEYbfGXW70ceyB8AbF-q9gkbvawVrBjyB87A2skQ@mail.gmail.com
Navajeeth,

Have you tried reverting to a previous generation? This should have a
working version of Emacs, etc. You should be able to do this from the
console without entering your window manager.

Something along the lines of

guix package -S <previous generation>

or even

guix package --roll-back

to get you back to the previous working generation

Good luck!
Attachment: file
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 75817@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 75817
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch