Snap layouts

@zyga-snapd I think I have identified an edge case issue with layouts. Mounting directories and files works fine, but if I declare two target paths for bind-file where the second path’s last component (i. e. filename) contains all of the first path’s plus a suffix, snap installation will fail with:

error: cannot perform the following tasks:
- Setup snap "my-snap" (unset) security profiles (cannot setup mount for snap "my-snap": cannot update mount namespace of snap "my-snap": cannot update preserved namespace of snap "my-snap": cannot update snap namespace: no such file or directory)
- Setup snap "my-snap" (unset) security profiles (cannot update mount namespace of snap "my-snap": cannot update preserved namespace of snap "my-snap": cannot update snap namespace: no such file or directory)

My layout definition:

$SNAP/api/Gemfile:
    bind-file: $SNAP_DATA/Gemfile
$SNAP/api/Gemfile.lock:
    bind-file: $SNAP_DATA/Gemfile.lock

As you can see, the second target path just adds .lock to the filename. If I rename the first mount “Gemfile” to “Gemfile_B”, everything works fine – but this breaks my Rails application. I can configure an alternative name for Gemfile, but Rails expects a $filename.lock file for whatever name I choose. To rule out that layouts has a problem with suffix-less files, I tried a layout with Gemfile.gems and Gemfile.gems.lock to no avail.

I also tested it with bind folders (attempting to mount $SNAP/folder alongside $SNAP/folder.suffix) just to make sure it’s not specific to bind-file.

Am I “holding it wrong” ™ or is this actually an issue with the layouts feature?