afewmail / afew

an initial tagging script for notmuch mail
ISC License
325 stars 96 forks source link

MailMover fails when notmuch config is not in default location #236

Open muradm opened 5 years ago

muradm commented 5 years ago
$ afew -C $HOME/.config/notmuch/my@email.com -vv --move-mails  
INFO:root:checking mails in 'Inbox'
DEBUG:root:query: folder:"Inbox" AND NOT tag:inbox AND tag:archive
DEBUG:root:moving mail
DEBUG:root:    b'[2019-05-17 17:35:24] Some message to be moved'
DEBUG:root:from 'Inbox' to 'Archive'
INFO:root:updating database
Configuration file /home/user/.notmuch-config not found.
Try running 'notmuch setup' to create a configuration.
ERROR:root:Could not update notmuch database after syncing maildir 'Inbox': Command '['notmuch', 'new']' returned non-zero exit status 1.

Here probably have to pass that config.

GuillaumeSeren commented 5 years ago

Hello, this is interresting case I think you could just use the variable $NOTMUCH_CONFIG to set your config file, but I aggree this is misleading and should be fixed, see: https://github.com/afewmail/afew/blob/e3968d6f0b709ef32da9d3fb597de0acc1c140bc/afew/commands.py#L65

I have checked a bit the notmuch way to pass a different config file you can use the variable or use '--config=' so we could use that to fix you problem, as I dont have the envirronment to test it well I suggest you go ahead and test this fix and submit a pull-request after that. https://notmuchmail.org/manpages/notmuch-1/

Anyway this need to be fixed, so if I can not help you make the patch, I will fix it on my own.

Vinfall commented 1 year ago

I think you could just use the variable $NOTMUCH_CONFIG to set your config file

As notmuch itself respect XDG_CONFIG_HOME environment variable now (see https://notmuchmail.org/manpages/notmuch-config-1/), if a user set XDG_CONFIG_HOME but not NOTMUCH_CONFIG, afew cannot find the notmuch config at $XDG_CONFIG_HOME/notmuch/default/config.

This could be and is a real problem if one wants to use only XDG_CONFIG_HOME and avoid NOTMUCH_CONFIG.

If I didn't miss anything, NotmuchSettings.py currently only check NOTMUCH_CONFIG environment variable, before falling back to the default ~/.notmuch-config.

https://github.com/afewmail/afew/blob/aa6661dc9ed877ac21b30534542fc785bf6cef6b/afew/NotmuchSettings.py#L11-L24

The implementation seems trivial so I may propose a PR by the end of the month.