todotxt / todo.txt-cli

☑️ A simple and extensible shell script for managing your todo.txt file.
http://todotxt.org
GNU General Public License v3.0
5.55k stars 712 forks source link

`~/.todo/config` not created during install in WSL 2 due to Permission Error #391

Closed sohang3112 closed 2 years ago

sohang3112 commented 2 years ago

Do you want to request a feature or report a bug? A bug.

What is the current behavior? While following the install instructions for Linux, folder ~/.todo was not created due to some permission issue. So when I ran todo.sh, it showed the error Fatal Error: Cannot read configuration file /home/sohang/.todo/config.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. After cloning this repository and doing cd <REPOSITORY-PATH>:

> make && make install                                                                                                                      
VERSION=2.12.0
make: 'VERSION-FILE' is up to date.
mkdir -p /usr/local/bin \
         /usr/local/etc/todo \
         /usr/local/share/bash_completion.d
mkdir: cannot create directory ‘/usr/local/etc/todo’: Permission denied
mkdir: cannot create directory ‘/usr/local/share/bash_completion.d’: Permission denied
make: 'VERSION-FILE' is up to date.
mkdir -p /usr/local/bin \
         /usr/local/etc/todo \
         /usr/local/share/bash_completion.d
/usr/bin/install todo.sh /usr/local/bin/todo.sh
/usr/bin/install -m 644 todo_completion /usr/local/share/bash_completion.d/todo
[ -e /usr/local/etc/todo/config ] || \
    sed "s/^\(export[ \t]*TODO_DIR=\).*/\1~\/.todo/" todo.cfg > /usr/local/etc/todo/config

> todo.sh                                                                                                                                   
Fatal Error: Cannot read configuration file /home/sohang/.todo/config

Note: I found a workaround for this (manually creating ~/.todo/config) but that should have been done automatically.

What is the expected behavior? Config file ~/.todo/config should be created during install.

Which versions todo.sh are you using?

Run todo.sh -V TODO.TXT Command Line Interface v@DEV_VERSION@

Which Operating System are you using? WSL 2 (Ubuntu 20.04), Host is Windows 11

Which version of bash are you using?

Run bash --version 5.0.17(1)-release (x86_64-pc-linux-gnu)

inkarkat commented 2 years ago

The Linux installation via make install does a system-wide install of todo.sh; it does not create a config file for the current (or even all) users.

Now, if you follow the instructions to the letter and use the configuration parameter CONFIG_DIR=/etc, then the global configuration will be installed in /etc/todo/config, and that location will be picked up as it's one of the default config locations, so you wouldn't get the Fatal Error: Cannot read configuration file error.

However (details in #377 and a documentation improvement in #379), the configuration that gets installed by make install (whether picked up automatically as default config or not), is meant to be a template that users can use as a basis for their own configuration - many users want to customize the colors or behavior, and on Linux there's a clear separation between a global config template (often in /etc) and the user's individual actual configuration (in their home directory).

So, when make install failed for you, you should have fixed the permission issue, either by using something like sudo make install to obtain the admin rights, or by opening the directory permissions, or by choosing different writable directories via the config parameters. Creating a user configuration is not part of make install.

I'm sorry that you've been misled; initially, the "installation" was just a manual copying of the very few files (program, completion, config template), now we have a customizable Makefile, but the documentation still isn't perfect here, and no matter what, installation via Makefile will always remain unnatural for "ordinary" users. I hope that in the future, more distributions (currently only Arch) will offer a package that will automatically install everything correctly.

Your "workaround" of manually creating your user's config is exactly what's expected of a new todo.sh user. I hope you'll still like the tool!

sohang3112 commented 2 years ago

The details you mentioned here should be part of the documentation - maybe you could add a file called NEW-TO-MAKE.md and link to that? Especially the part about about running make installas root should definitely be written in the install instructions.

inkarkat commented 2 years ago

Yes, details will be added. Most users unfortunately don't read documentation, especially not separate files (even if they are SCREAMING).

Installing via Makefile has always been ./configure && make && sudo make install - I've known this for decades ;-) But this just applies to (apparently old and grey) Unix developers - my point was that the tool should not expect ordinary users to know such things. A Makefile fundamentally is the wrong approach, and we'll never make this user-friendly - install packages are, though.