On BlackArch Linux we packaged cook this way: https://github.com/BlackArch/blackarch/blob/master/packages/cook/PKGBUILD
As for all ArchLinux packages, cook binary is deployed under /usr/bin/cook
and config files under /urs/share/cook
(eg. /usr/share/cook/cook.yaml
).
Launching cook like that just fails because cook is not able to find it's configuration file
$ cook a
2021/12/04 16:31:56 Err: Parsing YAML yaml: unmarshal errors:
line 1: cannot unmarshal !!str `Not Found` into map[string][]string
So as a workaround the user is forced to either define the conf file path with the environment variable or the parameter
$ cook a -config-path /usr/share/cook/cook.yaml
It's happening because this was implemented rather than what I suggested.
I don't really know where cook is looking for it's config file because even if you copy cook.yml
under /usr/bin
or in the working directory cook won't find it.
There are 2 solutions to that:
Solution 1
Implementing a XDG compliant config deployment cf. #13 (reply in thread)
Solution 2
define a go BUILD variable to defined the install path, so when the binary is build any linux distro maintainer would be able to define INSTALLDIR=/usr/bin/cook
and cook would look here for it's config file.
Idea
I think any tool creator should think about "how OS maintainers/packagers will deploy my tool on their OS" rather than assume that people will just git clone the tool cd in the repo and do ./tool
. Else it prevent for mass deployment on OSes or complexify the work of OS packagers.