Redirecting snapcraft output

I understand that snapcraft is a classic snap that runs in an AppArmor scope (what’s the correct word?) that is “almost unconfined”.

As of now, this prevents it from inheriting file descriptors from other scopes, if I am correct. This also implies that something like snapcraft &> /dev/null fails with permission errors. At least that’s what I’m experiencing and I hope I’m deducing the cause correctly here.

Is there a trick to redirect output regardless? E.g. to throttle it or limit line length etc.

Strange. Despite AppArmor, launching snapcraft is like launching any other process:

$ ls -l /snap/bin/snapcraft
lrwxrwxrwx 1 root root 13 Apr  9 20:31 /snap/bin/snapcraft -> /usr/bin/snap
$ ls -l /snap/snapcraft/current/bin/snapcraft 
-rwxr-xr-x 1 root root 396 Mar 17 22:59 /snap/snapcraft/current/bin/snapcraft

As you can see snapcraft is actually a link to /usr/bin/snap which in turn spawns /snap/snapcraft/current/bin/snapcraft (the exact path may differ across Linux distributions).

I cannot reproduce the permission errors:

$ snapcraft 
Could not find snap/snapcraft.yaml. Are you sure you are in the right directory?
To start a new project, use `snapcraft init`
$ snapcraft &> /dev/null

Can you provide an example?

That’s really strange. On my work PC, piping and redirecting output from snapcraft does not throw such errors. And no AppArmor denied logs either.

I’ll have to check my notebook again.