Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

todo.sh doesn't know about CONFIG_DIR #377

Open
derek-pryor opened this issue Mar 25, 2022 · 4 comments · May be fixed by #379
Open

todo.sh doesn't know about CONFIG_DIR #377

derek-pryor opened this issue Mar 25, 2022 · 4 comments · May be fixed by #379

Comments

@derek-pryor
Copy link

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 the CONFIG_DIR variable to where you want todo.cfg file to be installed. The install works as expected and the config file will be created where CONFIG_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 a CONFIG_DIR that is not one of those directories then todo.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.

  1. Install using the following command make install CONFIG_DIR=/home/(user)/.local/config INSTALL_DIR=/home/(user)/.local/bin BASH_COMPLETION=/home/(user)/.bash_completion.d
  2. Run ~/.local/bin/todo.sh -h

What is the expected behavior?
Either the make install command should set something in todo.sh to know what the CONFIG_DIR / sysconfdir was set to or Update the README to at least note that todo.sh only searches for the config file in the list of specific locations.

Which versions todo.sh are you using?

Run todo.sh -V
v2.12.0 - installed from the repository at that label

Which Operating System are you using?
Ubuntu 20.04 LTS via WSL2

Which version of bash are you using?

Run bash --version
5.0.16(1)-release

@inkarkat
Copy link
Member

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.

remedies

proposal A

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).

proposal B

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.

proposal C

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.

@derek-pryor
Copy link
Author

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.

inkarkat added a commit to inkarkat/todo.txt-cli that referenced this issue Mar 28, 2022
And only coincidentally picked up as the global configuration (if CONFIG_DIR=/etc).

Fixes todotxt#377
@inkarkat inkarkat linked a pull request Mar 28, 2022 that will close this issue
3 tasks
@ecjtusbs
Copy link

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?

@inkarkat
Copy link
Member

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)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants