Search notes:

Snap

Snap is a software packaging system for Linux running systemd.

Installing and testing (Debian)

Install the snap deamon:
$ sudo apt  install -y snapd
Install snap packages core and hello-world:
$ sudo snap install core
…
core 16-2.60.4 from Canonical✓ installed

$ sudo snap install hello-world
…
hello-world 6.4 from Canonical✓ installed
Trying to execute hello-world:
$ hello-world
-bash: hello-world: command not found
Opening a new console/bash session:
$ hello-world
Hello World!

$ which hello-world
/snap/bin/hello-world

$ file /snap/bin/*
/snap/bin/hello-world:      symbolic link to /usr/bin/snap
/snap/bin/hello-world.env:  symbolic link to /usr/bin/snap
/snap/bin/hello-world.evil: symbolic link to /usr/bin/snap
/snap/bin/hello-world.sh:   symbolic link to /usr/bin/snap

$ /snap/bin/hello-world

$ /snap/bin/hello-world.env
…
SNAP_EUID=1000
SNAP_USER_COMMON=/home/rene/snap/hello-world/common
…
SNAP_CONTEXT=jU0F2cC2cYgs-Kb8qwgeZlFwO1qwl1C4Ih_ga8VpmqQpa33ixT3j
…
USER=rene
NVM_DIR=/home/rene/.nvm
NAME=debian-wsl
…
SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void
SNAP_INSTANCE_NAME=hello-world
SNAP_COMMON=/var/snap/hello-world/common
SNAP_USER_DATA=/home/rene/snap/hello-world/29
SNAP_DATA=/var/snap/hello-world/29
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
_=/usr/bin/env
SNAP_REAL_HOME=/home/rene
PWD=/home/rene
LANG=en_US.UTF-8
SNAP_REVISION=29
HOME=/home/rene/snap/hello-world/29
SNAP_NAME=hello-world
SNAP_COOKIE=jU0F2cC2cYgs-Kb8qwgeZlFwO1qwl1C4Ih_ga8VpmqQpa33ixT3j
TMP=/tmp
LOGNAME=rene
SNAP_VERSION=6.4
…
SNAP_UID=1000
SNAP=/snap/hello-world/29
SNAP_INSTANCE_KEY=

$ /snap/bin/hello-world.evil
Hello Evil World!
This example demonstrates the app confinement
You should see a permission denied error next
If you see this line the confinement is not working correctly, please file a bug

$ /snap/bin/hello-world.sh
Launching a shell inside the default app confinement. Navigate to your
app-specific directories with:

  $ cd $SNAP
  $ cd $SNAP_DATA
  $ cd $SNAP_USER_DATA

$ ls -l ~/snap/
total 4
drwxr-xr-x 4 rene rene 4096 Dec 18 16:29 hello-world

TODO

How does Snap relate to Docker?

See also

/snap

Index