Snap refresh broken when output is piped

snap refresh core breaks under Ubuntu 18.04, if the output is piped.

100% reproducible:
snap refresh core | cat

->

error: cannot refresh "core": unexpectedly empty response from the server (try
       again later)

This is a big problem when using automation tools like Fabric.

1 Like

Thanks for reporting this bug, I can reproduce it too

Hmm, I cannot reproduce, I wonder what am I missing? On my test 18.04 system I had all snaps up-to-date, so in order to reproduce it I forced edge channel with sudo snap refresh --edge core|cat (and then did the same with --stable). When forcing edge the snap had to be downloaded from the store.

Could it be just a temporary store issue? Can you still reproduce it (and does it happen with all snaps)?

Could this be coincidence? Sometimes the store sends empty replies in times of overly high load for some requests.

Hmm now I cannot reproduce this anymore either :thinking: perhaps there was some sort of store outage at the time? But I could refresh core when not piping the output which was very odd. To be clear, what I did at the time to reproduce it was:

snap switch core --edge # was on stable before
snap refresh --list # verify that there is a refresh available
snap refresh core | cat # fails
snap refresh core # works
snap remove core --revision=<the-one-on-stable>
snap switch core --stable
snap refresh --list # verify that there is still a refresh available now
snap refresh core | cat # fails
snap refresh core # works

I unfortunately had snapd logs rotated since when I initially tried this, so Iā€™m not sure if there was indeed a store issue at that point in time or not.

I can confirm this, right now it says snap "core" has no updates available. But when I opened the thread I could reproduce it 100%. No matter how many times I run without pipe it always worked and with pipe it always failed.