Open derek-pryor opened 2 years ago
Even with a default installation, sysconfdir = $(prefix)/etc
with prefix = /usr/local
defaults to a config location of /usr/local/etc/todo/config
, which also is not considered by todo.sh
.
For a long time, users had to customize the configuration, at least to provide the TODO_DIR
location. Then, this got defaulted to the script's directory, now it's the user's home directory. Though this avoids errors when todo.sh
itself is installed in a system location, most users likely will still need to modify TODO_DIR
- who wants the task files right in their home directory?!
Therefore, the config file as installed served as a template only; user(s) were meant to at least copy it into their home directory, and modify it from there. (This is especially important for multi-user setups; though most systems today just have a single active user.)
In 2013, this commit allowed the use of global config file, looking in /etc/todo/config
.
In 2017, the /usr/local
prefix was introduced, but without adapting the global default.
I think the default for the global config location should be changed from /etc/todo/config
to <todo.sh-dir>/../etc/todo/config
. So a default prefix would look in /usr/local/etc/todo/config
, as the script itself is /usr/local/bin/todo.sh
. This would also work for prefix=/opt
, but now for prefix=/usr
- there's no /usr/etc/...
; instead, /etc/todo/config
would be correct, so that (current) global default would need to be kept as a fallback. (I think the /usr
prefix should not be used for manual installations, as that directory is meant for installation packages; that's a bad default in the Readme. I guess distribution packagers don't use prefix=/usr
(but rather CONFIG_DIR=/etc INSTALL_DIR=/usr/bin
), so there haven't been any complaints so far about that misplaced config template.)
Note that you (the submitter) would then have to use CONFIG_DIR=/home/(user)/.local/etc
instead of CONFIG_DIR=/home/(user)/.local/config
(or just shorter prefix=/home/(user)/.local
).
The Readme can certainly be interpreted the way you did (that CONFIG_DIR
will install the default config and make todo.sh
look for it there). The Makefile could preprocess that location into the script itself to achieve this. However, I'm not particularly fond of the added processing and the fact that we then end up with scripts that are functionally different depending on the build parameters.
Just add some clarifications in the Readme. When I encountered todo.sh
for the first time several years ago, it was nothing more than a checkout or ZIP archive that should be put somewhere in the PATH. A lot of install machinery has been added; unfortunately, it's not 100% consistent right now. I do wonder whether any effort in this direction is really worth it, so it might be wise to just do a few tweaks to the Readme and leave it at that.
I think just updating the README with a little more information would help. As you point out this is not a simple solution to automate and unless this becomes a bigger sticking point it may not be worth the effort and complexity to change the code.
after follow the install guide on readme page, I meet a error: Fatal Error: Cannot read configuration file /home/ckw/.todo/config. Am I missing something?
after follow the install guide on readme page, I meet a error: Fatal Error: Cannot read configuration file /home/ckw/.todo/config. Am I missing something?
@ecjtusbs The installation only installs a configuration template (by default at /etc/todo/config
); just copy that file to /home/ckw/.todo/config
and you're good (for your first steps; you can then tweak your personal config if necessary)!
Do you want to request a feature or report a bug? A bug or a mismatch in documentation
What is the current behavior? In the README the instructions on installing via
make install
talk about setting theCONFIG_DIR
variable to where you want todo.cfg file to be installed. The install works as expected and the config file will be created whereCONFIG_DIR
points.The problem is that
todo.sh
only searches for config files in the following locations https://github.com/todotxt/todo.txt-cli/blob/master/todo.sh#L693. So if you specify aCONFIG_DIR
that is not one of those directories thentodo.sh
fails with the following message:Fatal Error: Cannot read configuration file /home/(user)/.todo/config
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
make install CONFIG_DIR=/home/(user)/.local/config INSTALL_DIR=/home/(user)/.local/bin BASH_COMPLETION=/home/(user)/.bash_completion.d
~/.local/bin/todo.sh -h
What is the expected behavior? Either the
make install
command should set something intodo.sh
to know what theCONFIG_DIR
/sysconfdir
was set to or Update the README to at least note thattodo.sh
only searches for the config file in the list of specific locations.Which versions todo.sh are you using?
Which Operating System are you using? Ubuntu 20.04 LTS via WSL2
Which version of bash are you using?