56

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?

2 Answers 2

50

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.

8
  • 4
    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
    Commented Nov 8, 2020 at 3: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
    Commented Jul 11, 2021 at 6:17
  • 1
    @y_159 To download the snap again, you'll have to clear the cache first (sudo rm /var/lib/cache/snapd/*).
    – mook765
    Commented Jul 11, 2021 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
    Commented Jul 11, 2021 at 12:20
  • 1
    @y_159 Then don't clear the cache. Just removing and installing will not attempt to download again.
    – mook765
    Commented Jul 11, 2021 at 12:30
5

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
3
  • Some explanation and code formatting would be nice Commented Sep 19, 2021 at 5:58
  • Also is unclear if that will maintain or restore the package previous settings, as required by the OP. Commented Nov 1, 2022 at 18:47
  • I guess sudo is also necessary for the command after &&. Without sudo, snap will ask for the password using a GUI window.
    – Melebius
    Commented Jun 6 at 7:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .