How can read ~/config.ini file by the snap binary?

I have made a snap version for my program, but it cannot read from my ~/config.ini config file, only can read configuration from environment variables . The ~/config.ini file content should be modified by our users .
So how can I read the config file work from the snap binary ?

Thank you .

If this path is actually correct ( ~/config.ini, no dot…) you can definitely use the home interface for your app.

That said, you should really use the $SNAP_USER_DATA dir for this instead (automatically pointing to ~/snap/<snapname>/current/) and teach your application to store its config there. This will work without any interfaces.

Hi, you mean that for the snap app , ~/config.ini is the ~/snap/<snap_app_name>/current/config.ini ,right ? But I cannot modify the ~/snap//current/config.ini, because it’s a readonly file system. I want the config.ini can be modified by user accoring to their own AccoutID and password.

note: /snap is not ~/snap …
the latter is underneath your homedir, the former is a system dir.

In the snap environment your apps can access the first one through the $SNAP environment variable and the second one via $SNAP_USER_DATA.

By the way , how can I install snap app in CentOS system ? Thank you .

I dont think CentOS supports snaps yet, only fedora does (@Conan_Kudo or @zyga-snapd might have more info on the status regarding CentOS)

Hi @luluhongxu! Maybe you want to support this request too…

@ogra I have been waiting for the Go compiler rebase in CentOS 7.4 before trying again. CentOS 7.4 comes with golang 1.8.3 as opposed to golang 1.6.3 in CentOS 7.3.

There’s also a few other things I was waiting for before trying again, but the Go compiler was the biggest one.

1 Like