Where to save stuff (in snap-agnostic way)

Luca Dionisi luca.dionisi at gmail.com
Sat Feb 4 08:42:43 UTC 2017


Thanks all for the answer.

There's a catch, though. I just checked in a classic Ubuntu what the
XDG_RUNTIME_DIR env is set to for root. And, surprise, it's not set.
So, since my app has to run as root, it seems that I'll have to check
this possibility too.

--Luca

On Sat, Feb 4, 2017 at 3:47 AM, XiaoGuo Liu <xiaoguo.liu at canonical.com> wrote:
> Hi Seth,
>
> Thanks. You are right. I just created a new dir under the root, and I tried
> to access it, and it was successful this time.
>
> liuxg at liuxg:~/snappy/desktop$ sudo snap run --shell hello.env
> [sudo] password for liuxg:
> root at liuxg:/home/liuxg/snappy/desktop# cd /run/user/0/snap.hello
> root at liuxg:/run/user/0/snap.hello# ls
>
> Many thanks
> Best regards,
> XiaoGuo
>
> On Sat, Feb 4, 2017 at 10:40 AM, Seth Arnold <seth.arnold at canonical.com>
> wrote:
>>
>> On Sat, Feb 04, 2017 at 10:33:20AM +0800, XiaoGuo Liu wrote:
>> > liuxg at liuxg:~/snappy/desktop/ss$ hello.env | grep XDG_RUNTIME
>> > XDG_RUNTIME_DIR=/run/user/1000/snap.hello
>> > $ sudo snap run --shell hello.env
>> > # env | grep XDG_RUNTIME_DIR
>> > XDG_RUNTIME_DIR=/run/user/0/snap.hello
>>
>> Your first command was run as a standard user, probably the first user
>> installed on the system, since it is user 1000.
>>
>> Your second command was run as root via the sudo tool, thus you get a
>> different directory. Every user's data should be stored in a place where
>> it won't collide with other users, and root is no different in this case.
>>
>> Thanks
>>
>> --
>> Snapcraft mailing list
>> Snapcraft at lists.snapcraft.io
>> Modify settings or unsubscribe at:
>> https://lists.ubuntu.com/mailman/listinfo/snapcraft
>>
>
>
>
> --
> XiaoGuo, Liu
>
> --
> Snapcraft mailing list
> Snapcraft at lists.snapcraft.io
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/snapcraft
>




More information about the Snapcraft mailing list