Lxd snap not refreshing (says it is local, but it isn't)

Not sure if the forum is the proper place for this as it seems like a bug report… Please tell me to file as a bug if that is better.

$ snap version
snap    2.24.1+17.04
snapd   2.24.1+17.04
series  16
ubuntu  17.04
kernel  4.10.0-20-generic

$ snap info lxd
name:      lxd
summary:   "LXD - the container lighervisor"
publisher: 
description: |
  LXD is a container manager for system containers. It offers a REST API to
  remotely manage containers over the network, using an image based workflow and
  with support for live migration.
commands:
  - lxd.benchmark
  - lxd.lxc
  - lxd
tracking:    candidate
installed:   2.5 (241) 13MB -
refreshed:   2016-10-25 20:15:23 -0500 CDT
channels:                       
  stable:    2.12        (1743) 12MB -
  candidate: 2.13        (2071) 12MB -
  beta:      2.13        (2071) 12MB -
  edge:      git-699f8fc (2108) 12MB -

$ sudo snap refresh lxd
error: cannot refresh "lxd": cannot refresh local snap "lxd"
[1]

$ sudo snap refresh lxd --stable
error: cannot refresh "lxd": cannot refresh local snap "lxd"
[1]

$ sudo snap refresh lxd --candidate
error: cannot refresh "lxd": cannot refresh local snap "lxd"
[1]

$ snap list
Name                     Version                  Rev   Developer      Notes
...
lxd                      2.5                      241                  -
...

What is weird is that snap refresh thinks this is a locally installed snap, but snap info clearly says I’m tracking ‘candidate’. snap list seems confused-- it has a revision from the store but no publisher.

Looking at other ‘snap list’ output, lxd is the only one in this state (ie, a store revision without a publisher).

@mvo on IRC told me the state.json file was messed and that it was missing the snap-id for this snap. I had two options:

  1. snap remove/install the lxd snap
  2. modify the state.json file

Since I didn’t want to lose my containers, I chose the second and did:

  1. sudo service snapd stop
  2. backed up /var/lib/snapd/state.json
  3. edited /var/lib/snapd/state.json to replace {"name":"lxd","snap-id":"","revision":"241"} with {"name":"lxd","snap-id":"J60k4JY0HppjwOjW8dZdYc8obXKxujRu","revision":"241"}
  4. sudo service snapd start

After doing this, snap list showed the publisher and I could refresh.

1 Like

Curious had you done a snap disable on it? I remember running into this issue several months ago after having done a disable and enable. I think there was a bug report opened for it.

Thanks for posting your workaround. Going to tuck that away for future use :grin:

Both @mvo and @pedronis on IRC recalled this bug. It is conceivable I did a disable/enable since I’ve used the mechanism a couple times for different things, but not routinely. I don’t recall if I did it for this snap.