63

I would like to reinstall a snap package due to a missing library file (removing and installing the snap again fixed this problem on another system).

How can I avoid the uninstall step (thus preserving my settings) and install again?

mook765
  • 18,764
RolandiXor
  • 51,957

2 Answers2

56

Unfortunately a command or option to reinstall a snap similar to apt install --reinstall does not exist. So removing and then installing the snap again is the only way.

But the settings of the snap will be saved in a snapshot while removing the snap unless you use the --purge-option, so just run snap remove snapname but not snap remove --purge snapname.

Check the snapshot with snap saved to see it's ID.

After installing the snap again you can restore the snapshot with snap restore ID and your settings are back.

mook765
  • 18,764
  • 6
    You're life saver! snap saved works even after snap remove someApp and then snap install someApp ! :) BTW: the "ID" of the snap is in the "Set" column (the first one) of the list you get from snap saved - that was super not-obvious for me :) – jave.web Nov 08 '20 at 03:01
  • 1
    Will this download the package again, say for vscode? I've to reinstall it without downloading it again due to low data balance. I installed it with snap on ubuntu18.04. – y_159 Jul 11 '21 at 06:17
  • 1
    @y_159 To download the snap again, you'll have to clear the cache first (sudo rm /var/lib/cache/snapd/*). – mook765 Jul 11 '21 at 12:00
  • @mook765 i just have to reinstalll it, like in windows you can remove the current installed application, and reinstall from the setup without having to download it again. – y_159 Jul 11 '21 at 12:20
  • i've to remove the current vscode and reinstall it from same setup in ubuntu. – y_159 Jul 11 '21 at 12:21
  • 1
    @y_159 Then don't clear the cache. Just removing and installing will not attempt to download again. – mook765 Jul 11 '21 at 12:30
  • so if i use snap remove code and then snap install code. It will reinstall without downloading again correct? – y_159 Jul 11 '21 at 12:32
6

You can use a command like this:

sudo snap remove <package name> && snap install <package name>

Because there is no reinstall option in snap package manager, we have to combine uninstall and install commands inorder to perform reinstallation in a single step, eg.:

sudo snap remove firefox && snap install firefox
Artur Meinild
  • 31,385