Subject: Boot fails when symlink exists

From: Pierre Neidhardt <[email-masked]>
Date: Fri, 02 Feb 2024 18:55:58 +0100

Today my Guix System crashed during the boot process for external
reasons.

Upon restart, booting a system would drop into the REPL right after the
following line:

--8<---------------cut here---------------start------------->8---
making '/var/...' the current system...
--8<---------------cut here---------------end--------------->8---

complaining that the symlink already exists.

I checked gnu/build/activation.scm (activate-current-system), and there
is this:

--8<---------------cut here---------------start------------->8---
  ;; Atomically make SYSTEM current.
  (let ((new (string-append %current-system ".new")))
    (symlink system new)
    (rename-file new %current-system)))
--8<---------------cut here---------------end--------------->8---

And indeed, there was a dangling /run/current-system.new file on my
disk.
After removing it (from a live USB, didn't know how to do this from the
Guile REPL), the system succeeded to boot.

The fix should be easy: ensure that (symlink system new) overwrites any
potentially existing file.

Cheers!
Pierre