Snap not seeing files in install directory

Hello, I am trying to package a very basic snap with two files in the source. One is an executable that hosts a webserver and the other is an html file.

When I run the executable outside of a snap, it works great and it can find the html file so long as it is in the same directory as the html file. However, when I install it as a snap and run it, it cannot find the html file anymore, even though both the executable file and the html file are stored in /snap/go-webserver/current.

Even when I install the snap and manually run the executable from the /snap/go-webserver/current directory using “./main” it works great. Also, when I make the snap containment classic, it works great. However, I cannot use classic containment because I am going to put this snap on an Ubuntu-Core image.

I tried adding plugs that gave the snap access to the $SNAP directory but that didn’t seem to change anything. Here is my current snapcraft.yaml

name: go-webserver
summary: Lightweight webserver to display a basic html file
description: |
      Created to display a basic loading html file until the PLC has started.
version: test
base: core22
confinement: strict
grade: stable
type: app

    interface: content
    content: binaries
    target: $SNAP/

    command: main
      - home
      - browser-support
      - network
      - network-bind
      - dot-config-go-webserver
    daemon: simple
    restart-condition: always

    plugin: dump
    build-snaps: [go/latest/stable]
    source: ./build

Any help would be greatly appreciated.

I think what should help you is defining more precise content plugs, plus using content: binaries to grab HTML file seems… Weird w.r.t naming. Link below should help more:

When it works in devmode, you can debug it easily using snappy-debug package which will point for you what needs to be adjusted.

I ended up just adjusting the go program’s relative file paths to be relative to the $SNAP environment variable. Thanks though!