Using components

A snap component is part of a snap that has been declared as optional. A snap component may then be either installed or not installed alongside its host snap. See Components for further details.

Component support requires snapd 2.67+.

Installing components

Components can be installed with the snap install command:

snap install my-snap+comp1+comp2

:information_source: The syntax <snap_name>+<comp_1>+...+<comp_N> will be used to refer to components from the command line.

The above command will install my-snap alongside components comp1 and comp2. If the snap is already installed, the command will instead install only the missing components.

It is also possible to install components from local files. If unasserted, they can be installed only if the host snap is unasserted too and you will need to use the --dangerous flag:

snap install --dangerous ./my-snap+comp1+comp2_1.0.comp

Once installed, the (asserted) components will refresh when new revisions are available in the store, in the same way as for snaps.

When refreshing a snap, all components will refresh to the new revisions tuple. If the new snap revision does not define some components defined in the previously installed snap and that are currently installed, those components will be removed.

Updating components

It is also possible to refresh a snap and install a component at the same time:

snap refresh my-snap+comp1

Listing components

The snap components command is used to list the components installed and available on the system:

$ snap components
Component                    Status     Type
snap-with-comps+one          installed  standard
snap-with-comps+two          installed  standard
snap-with-comps+three        available  standard
other-snap-with-comps+one    installed  standard
other-snap-with-comps+two    installed  standard
other-snap-with-comps+three  available  standard

A snap name can be optionally provided to filters the list of reported components to those only associated with the provided snap:

$ snap components snap-with-comps
Component                	Status 	Type
snap-with-comps+one      	installed  standard
snap-with-comps+two      	installed  standard
snap-with-comps+three    	available  standard
Note that there are some plans for a "snap component" subcommand, but that is not yet implemented and there are talks of changing its design.

Removing components

To remove only the components, use the “remove” command, followed by the snap and component names:

snap remove my-snap+comp1+comp2

To remove the snap plus any installed components, just remove the snap:

snap remove my-snap
1 Like

This is confusing given it comes right after the example for installing unasserted snaps/components; I wouldn’t expect these to refresh ever. I’d move it up to before the “It is also possible to install components from local files. …” line.

If I “refresh” an unasserted snap (snap install --dangerous ./my-snap_1.0.snap), I wouldn’t expect the components generated from the rebuild to automatically install, correct? Maybe we should mention that the components must likewise be reinstalled to update them.

Is this also true just in case the snap I am refreshing is an unasserted snap?