So, I did run the snapctl inside a snap shell as well
test1@localhost:/home/test1$ env | grep CONTEXT
SNAP_CONTEXT=-zW8yoHmXaxQfUzVcNxy39iP-2qphTU2aJNkib2XgUtk3QM3olwy
test1@localhost:/home/test1$ snapctl get core
test1@localhost:/home/test1$ sudo snapctl get core
error: error running snapctl: cannot get without a context
test1@localhost:/home/test1$
well, it returned {} … i’m not sure an unprivileged snap is actually allowed to query/set core settings without using snapd-control and the snapd REST API …
well, did you also add/connect the snapd-control plug before attempting to use snapd-glib ? just using the library does not magically grant access for your snap to the REST API.
with unprivileged i mean a snap not using the REST API and not using the extra privileges the snapd-control interface grants …
well, i’m not sure if snapd-control works for locally installed snaps, it is tightly tied to brand stores so it might not work easily without one … (i have never played with it outside of a brand-store context)
Well, this is a brand store app. A basic version is present in store. Since I am enhancing it, I am not pushing it store and installing. Instead I’m building the snap in host, scp’ing it to device and then installing in devmode.
I was wrong in using the snap that I did for this experiment. It did not have snap-declaration for snapd-control. When used within a snap having snapd-control declaration, this worked.
Also, understood that snapctl works only in context of a snap. When run in a shell of snap (using sudo snap run --shell .) with following code, able to get output.