$SNAP without version

So I’m trying to preinstall a config file for a service containing a webserver. One of the values in the config file should be the path to the webserver public folder which is also shipped in the same snap package and installed to

/snap/<package>/<version>/webinterface

The only way so far that I have found to generate such a config file is to wrap my binary in a script that will copy the template conf file into $SNAP_COMMON if there isn’t one there yet and then use sed to replace @WEBDIR@ with the above path. So, the obvious variable to use there is $SNAP/webinterface, however, this will break on upgrades as the config file in $SNAP_COMMON would still point to the old version.

Is there a variable that would point me to /snap/<package>/current/ instead of /snap/<package>/<version>/ ?

There is no variable that says current at this time. Having said that you can “hack” this a bit by $SNAP/../current. Not sure if this is helpful.

Yeah, I thought of this, but was a bit worried it might fail in some circumstances…

Though right now the current symlink exists, at some future time we may remove it. I don’t think we would do so in a backwards incompatible manner though. For the moment I think it is okay to use this if it makes your life easier.