Nextcloud 22.1.1 snap update not working

Hallo!

I’m running a Ubuntu 20.04 machine with nextlcoud snap (22.1.1) installed and an certificate from let’s encrypt.
Works perfectly well. However, update does not.

Executing:

sudo snap refresh nextcloud
2022-12-19T22:40:00Z INFO Waiting for "snap.nextcloud.mysql.service" to stop.
error: cannot perform the following tasks:
- Run post-refresh hook of "nextcloud" snap if present (run hook "post-refresh": Nextcloud doesn't support skipping major versions, you must upgrade to Nextcloud 23 first. Try 'sudo snap refresh nextcloud --channel=23')

Executing as suggested:

sudo snap refresh nextcloud --channel=23
2022-12-19T22:42:53Z INFO Waiting for "snap.nextcloud.mysql.service" to stop.
error: cannot perform the following tasks:
- Run configure hook of "nextcloud" snap if present (run hook "configure": error: error running snapctl: snap "nextcloud" option "ports" is not a map)

Syslog is the same in both cases:

Dec 19 22:43:11 server nextcloud.apache[427530]: error: error running snapctl: snap "nextcloud" option "ports" is not a map
Dec 19 22:43:11 server nextcloud.apache[427546]: error: error running snapctl: snap "nextcloud" option "ports" is not a map
Dec 19 22:43:11 server nextcloud.apache[427562]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

What am I doing wrong?

Thanks for your help!

Your configuration sounds wrong. Can I see the output of sudo snap get nextcloud ports, please?

Thanks for helping me!

sudo snap get nextcloud ports
443

That’s all

Huh, no idea how you managed to get it into that state. Try this: sudo snap set nextcloud ports.http=80 ports.https=443. If that is successful, you should be able to update to v23 and beyond.

Not succesfull:

bil@server:~$ sudo snap set nextcloud ports.http=80 ports.https=443
error: cannot perform the following tasks:
- Run configure hook of "nextcloud" snap (snap "nextcloud" option "ports" is not a map)

too bad, what else can I do?

Okay then it’s time for no-warranty hacky mode, bear with me:

Open up /var/lib/snapd/state.json as root. It will be a little difficult to navigate, but look through there until you find this:

"nextcloud":{"http":{"compression":false},"mode":"production","nextcloud":{"cron-interval":"5m"},"php":{"memory-limit":"512M"}, ...

This is snapd’s “database” for the settings you’re trying to update. In that json object, I assume you’ll find "ports": 443 or some such invalid thing. It needs to be an object instead of a scalar: "ports":{"http":80,"https":443}. Note that there will be two of them you need to update, one in nextcloud.ports, one in nextcloud.private.ports. Make them look identical.

Once you’re happy with it, save and exit that file. Then restart snapd:

$ sudo systemctl restart snapd

Finally, restart the Nextcloud snap:

$ sudo snap restart nextcloud

Then run the same query as before:

$ sudo snap get nextcloud ports

Any better?

Hello,

First of all, I am sorry to barge in and hijacking the thread by going little off topic,

But I have a question here, just for better understanding. I need little explanation on this comment of yours

If I am running my Nextcloud Snap on nonstandard HTTP and HTTPS port, will it stop updating itself?

Just to elaborate, I have Nextcloud Snap running on nonstandard HTTP and HTTPS port with custom (my own domain) given SSL with a Sub domain.

Same machine is also having various other services and to make all accessible via Internet, I have Docker Nginx Reverse Proxy Manager running to manage port 80/443 and forward subdomains (traffic) to their respective services via different ports.

Just to be clear, I don’t have any problem, everything is running just fine but since you commented, I wonder, will this setup stop my Snap Nextcloud from updating itself?

Once again, apologies for hijacking the thread and asking something little off topic.

Thanks.

I’m not running Nextcloud on nonstandard ports. At least not intentionally.

I found this:

"nextcloud":{
"mode":"production","nextcloud":{
"cron-interval":"5m"},
"php":{
"memory-limit":"512M"},
"ports":443,"private":{
"mode":"production","nextcloud":{
"cron-interval":"5m"},
"php":{
"memory-limit":"512M"},
"ports":{
"http":80,"https":443},
"snap":{
"version":"22.1.1snap2"}
}
}

and

"nextcloud":{
"28549":{
"mode":"production","nextcloud":{
"cron-interval":"5m"},
"php":{
"memory-limit":"512M"},
"ports":443,"private":{
"mode":"production","nextcloud":{
"cron-interval":"5m"},
"php":{
"memory-limit":"512M"},
"ports":{
"http":80,"https":443},
"snap":{
"version":"22.1.1snap2"}
}
}
}

so ports is there twice.

I used following line to remove the wrong parts:
sed -i 's+"ports":443,++g' state.json

So now it looks promising, i guess.

me@server:~$ sudo snap get nextcloud ports
Key          Value
ports.http   80
ports.https  443

Update works now! Thank you very much.

1 Like

Oh heavens no, although I can see how you might misunderstand my comment. The issue here wasn’t that @bil’s config was using a non-standard port, but it was somehow completely invalid. ports needs to be an object containing a http and https key, specifying ports for each, not just a scalar value like @bil had. As long as your config has the http and https key and they are valid ports, you won’t run into any issues: the snap will continue to update as it always has.

1 Like