Skip to content

Environment Variables

Zygmunt Krynicki edited this page Feb 17, 2017 · 4 revisions

Environment variables

This page documents various environment variables available to snap applications.

Snappy specific environment variables

SNAP_NAME

The name of the snap as specified in the snapcraft.yaml file.

Typical value: hello-world

SNAP_VERSION

The version string as specified in the snapcraft.yaml

Typical value 6.3

SNAP_REVISION

Revision of the snap, as allocated by the store on upload or as allocated by snapd for locally installed snaps.

The store assigns monotonic revisions to each upload of a given snap. Snapd uses store revisions if accompanying assertions are available or uses a locally generated number. Locally generated numbers are prefixed with x to distinguish them from store uploads.

Typical value: 27 or x1

SNAP_ARCH

CPU architecture of the running system.

Typical value amd64

Other values are: i386, armhf, arm64.

SNAP

Directory where the snap is mounted. This is where all the files in your snap are visible in the filesystem. All of the data in the snap is read-only and cannot be changed.

Typical value: /snap/hello-world/27

SNAP_USER_DATA

Directory for user data.

This directory is backed up and restored across snap refresh and snap revert operations.

Typical value: /home/zyga/snap/hello-world/27

The final number there is $SNAP_REVISION.

SNAP_USER_COMMON

Directory for user data that is common across revisions of a snap.

Unlike SNAP_DATA, data present in this directory is not backed up or restored across snap refresh and snap revert operations. The directory is suitable for large data that the application can access even if it was made or modified by a future version of a snap.

Typical value /home/zyga/snap/hello-world/common

SNAP_DATA

Directory for system data of a snap.

This directory is owned and writable by root and is meant to be used by background applications (daemons, services). Unlike SNAP_COMMON this directory i backed up and restored across snap refresh and snap revert operations.

Typical value /var/snap/hello-world/27

SNAP_COMMON

Directory for system data that is common across revisions of a snap.

This directory is owned and writable by root and is meant to be used by background applications (daemons, services). Unlike SNAP_DATA this directory is not backed up and restored across snap refresh and revert operations.

Typical value: /var/snap/hello-world/common

SNAP_LIBRARY_PATH

Directory with additional system libraries. This variable is used internally by snapcraft. The value is always /var/lib/snapd/lib/gl: Please note the colon at the end of that value, the variable is a colon-separated list.

The referenced directory is typically empty unless Nvidia proprietary drivers are in use.

Generic variables

HOME

This environment variable is re-written by snappy so that each snap appears to have a dedicated home directory that is a subdirectory of the real home directory.

Typical value: /home/zyga/snap/hello-world/27

Since snapd 2.20 the HOME variable is not re-written when snap is under classic confinement.

PATH

This environment variable is re-written by snappy so that it is consistent with the view of the filesystem presented to snap applications. The value is always: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Since snapd 2.20 the PATH variable is not re-written when snap is under classic confinement.