Snapd cannot be configured

sudo snap set system refresh.retain=2 and sudo snap set core snapshots.automatic.retention=no output:

error: cannot perform the following tasks:

  • Run configure hook of “core” snap (run hook “configure”: cannot set hostname “System-Product-Name”: name not valid)

snap info core does output:

beedellrokejulianlockhart@System-Product-Name:~$ snap info core
name: core
summary: snapd runtime environment
publisher: Canonical✓
store-url: https://snapcraft.io/core
contact: snaps@canonical.com
license: unset
description: |
The core runtime environment for snapd
type: core
snap-id: 99T7MUlRhtI3U0QFgl5mXXESAiSwt776
tracking: latest/edge
refresh-date: today at 03:30 BST
channels:
latest/stable: 16-2.51.4 2021-08-25 (11606) 104MB -
latest/candidate: 16-2.51.7 2021-08-31 (11743) 104MB -
latest/beta: 16-2.52 2021-09-04 (11798) 104MB -
latest/edge: 16-2.52 2021-09-08 (11824) 104MB -
installed: 16-2.52 (11824) 104MB core

This is caused by the hostname that’s is not valid per hostname(7) man page as it uses capital letters (as as side note, I think we have a problem with validation in snapd in that it is more strict than the hostname man describes, but it’s not affecting your case).

Snapd validates various settings, including some that are collected from the system itself (such as hostname) even when modifying another setting (as is the case with refresh.retain that you gave), and refuses to do any changes if any setting is invalid. As a workaround you can set your hostname to “system-product-name” and that should fix the issue.

2 Likes

I have not used Snap recently, but if I do use it again, and I encounter this problem, I shall attempt ascertainment of whether your method of remediation of this problem is correct.

I am thankful for your assistance.

Thanks for your reply. This problem had been puzzling me for days before I read your answer.

1 Like

I’ve retroactively set that as the answer because although I’ve not encountered it again,

makes me think that it’s probably the solution.