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

Fresh brew install fails with Fatal Error: Cannot read configuration file /Users/me/.todo/config #252

Closed
jtpereyda opened this issue Apr 9, 2018 · 10 comments · Fixed by #316

Comments

@jtpereyda
Copy link

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
After a fresh install, first run yields the following message:

> todo.sh
Fatal Error: Cannot read configuration file /Users/me/.todo/config

Simple workaround is mkdir -p ~/.todo and touch ~/.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. Have not installed before (or maybe config file just doesn't exist)
  2. Install
  3. Run
  4. See warning

What is the expected behavior?
See help text.

Which versions todo.sh are you using?

Run todo.sh -V
v2.11.0

Which Operating System are you using?
OS X 10.13.3 High Sierra

Which version of bash are you using?

Run bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.

@jtpereyda
Copy link
Author

Installation may be more hosed than I realized:

> todo.sh add "test item"
Fatal Error:  is not a directory

@davidstosik
Copy link

The CLI defaults to looking for its config in $HOME/.todo/config:

TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-$HOME/.todo/config}

That folder and file do not get created on install with Homebrew. So it tries, to check for other paths:

todo.txt-cli/todo.sh

Lines 660 to 703 in d589fd0

[ -e "$TODOTXT_CFG_FILE" ] || {
CFG_FILE_ALT="$HOME/todo.cfg"
if [ -e "$CFG_FILE_ALT" ]
then
TODOTXT_CFG_FILE="$CFG_FILE_ALT"
fi
}
[ -e "$TODOTXT_CFG_FILE" ] || {
CFG_FILE_ALT="$HOME/.todo.cfg"
if [ -e "$CFG_FILE_ALT" ]
then
TODOTXT_CFG_FILE="$CFG_FILE_ALT"
fi
}
[ -e "$TODOTXT_CFG_FILE" ] || {
CFG_FILE_ALT="${XDG_CONFIG_HOME:-$HOME/.config}/todo/config"
if [ -e "$CFG_FILE_ALT" ]
then
TODOTXT_CFG_FILE="$CFG_FILE_ALT"
fi
}
[ -e "$TODOTXT_CFG_FILE" ] || {
CFG_FILE_ALT=$(dirname "$0")"/todo.cfg"
if [ -e "$CFG_FILE_ALT" ]
then
TODOTXT_CFG_FILE="$CFG_FILE_ALT"
fi
}
[ -e "$TODOTXT_CFG_FILE" ] || {
CFG_FILE_ALT="$TODOTXT_GLOBAL_CFG_FILE"
if [ -e "$CFG_FILE_ALT" ]
then
TODOTXT_CFG_FILE="$CFG_FILE_ALT"
fi
}

The last one it checks is /etc/todo/config. This does not exist either.

Oh and the one before tries $(dirname "$0")"/todo.cfg", unfortunately, when using Homebrew, dirname "$0" returns the folder containing the todo.sh symlink created by Homebrew, in /usr/local/bin.

This is not great. Here is what I would personally suggest, but I have no idea of all the constraints to take into account:

  1. Add the following attempt at finding a todo.cfg file:
[ -e "$TODOTXT_CFG_FILE" ] || {
   CFG_FILE_ALT="$(cd "$(dirname "$0")" && cd "$(dirname "$(readlink "$0")")" && pwd)/../todo.cfg"

   if [ -e "$CFG_FILE_ALT" ]
   then
       TODOTXT_CFG_FILE="$CFG_FILE_ALT"
   fi
}

This tries to follow the /usr/local/bin/todo.sh symlink, go up one folder, then pick todo.cfg. This is actually where the file is located when installing todo.txt-cli with Homebrew.

I'd also suggest changing the config's default TODO_DIR to $HOME/.todo.

@karbassi
Copy link
Member

karbassi commented Apr 19, 2018

Side note, when installing via homebrew, a caveat is displayed.

https://github.com/Homebrew/homebrew-core/blob/b820f78f54433fe3786221eaa5c22d43ca298d2d/Formula/todo-txt.rb#L16-L20

@marabesi
Copy link

Same is occurring here, I just created the config file but it gives me

                       
Fatal Error:  is not a directory

@danielmontenegro
Copy link

Thanks @karbassi: cp /usr/local/opt/todo-txt/todo.cfg ~/.todo.cfg (Mac OS X version with brew)

@karbassi karbassi closed this as completed Jul 6, 2018
@diegoquintanav
Copy link

diegoquintanav commented Aug 29, 2018

For those who landed here from a google result: I installed it from a clone in Ubuntu 18.04. This situation is explained in https://github.com/todotxt/todo.txt-cli/wiki/Troubleshooting and it is fixed by copying todo.cfg in ~/.todo.config

cp /path/to/repo/todo.cfg ~/.todo/config

@ghost
Copy link

ghost commented Aug 30, 2018

Great thanks it work ;-)

@genidma
Copy link

genidma commented Jun 29, 2019

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
After a fresh install, first run yields the following message:

> todo.sh
Fatal Error: Cannot read configuration file /Users/me/.todo/config

Simple workaround is mkdir -p ~/.todo and touch ~/.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. Have not installed before (or maybe config file just doesn't exist)
  2. Install
  3. Run
  4. See warning

What is the expected behavior?
See help text.

Which versions todo.sh are you using?

Run todo.sh -V
v2.11.0

Which Operating System are you using?
OS X 10.13.3 High Sierra

Which version of bash are you using?

Run bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.

This works. But you have to populate the config file. So after creating the directory & then the config file within it, edit the config file and place the contents from the following source within it (link below).
https://raw.githubusercontent.com/todotxt/todo.txt-cli/master/todo.cfg

@Yopai
Copy link

Yopai commented Feb 17, 2020

At the very minimum, shouldn't this step be noted in the documentation (after "Install" and before "Usage") ?

karbassi added a commit that referenced this issue Aug 12, 2020
Fixes #252 (by adding a note to README)
karbassi added a commit that referenced this issue Aug 12, 2020
Fixes #252 (by adding a note to README)
wwalker pushed a commit to wwalker/todo.txt-cli that referenced this issue Sep 19, 2021
@smaeder
Copy link

smaeder commented Jul 3, 2024

Side note, when installing via homebrew, a caveat is displayed.

https://github.com/Homebrew/homebrew-core/blob/b820f78f54433fe3786221eaa5c22d43ca298d2d/Formula/todo-txt.rb#L16-L20

The given caveat for me was incorrect. It gave:
cp /opt/homebrew/Cellar/todo-txt/2.12.0/todo.cfg ~/.todo.cfg

But what was needed, and worked, was:
cp /opt/homebrew/Cellar/todo-txt/2.12.0/todo.cfg ~/.todo/config

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.

9 participants