Access host machine's $PATH

I am working on publishing the Vicegerent app as a snap. The app lets you run commands specified in a config file invoked by an HTTP request.

For instance, the config might be to run docker-compose up upon receiving a request to some URL.

The app works fine outside a snap, but inside a snap it cannot find docker-compose up in the $PATH, although the snap is in devmode.

The app is written in Go and the commands are executed like that:

cmd := exec.Command('foo', 'bar')
err := cmd.Run()

How to fix that issue?

1 Like

You won’t be able to do this with a strict confined snap. Strict confined snaps run within a private mount namespace with their base snap used as a root file system to provide a consistent runtime environment no matter what distro release they are installed on. Of course, this isolation from the host system also means that you won’t be able to see applications, libraries, or data files installed on the host system.

If you instead use confinement: classic in your snap, it will be equivalent to running on the host system directly (with all the difficulties associated with trying to produce binaries that will run in any environment). That’s probably what you want for an application like this.

When you have your snap working, you’ll need to request permission on this forum to publish a classic snap (since they aren’t bound by the same security sandbox as strict confined snaps). You can read some details on what to expect from this here: