Require config only when really needed

I'm trying to use vmt pick ~/drafts to pick a single email from the maildir in $HOME/drafts (currently I run ag through these and honestly vmt pick would be a huge improvement).

However, it crashes right away indicating a missing configuration file:

13:31:33 [ERROR] Failed to load config file: error reading config file: No such file or directory (os error 2)

I tried creating an empty configuration file, but it still fails:

13:34:29 [ERROR] Failed to load config file: config error: no accounts found

At this point, I'm not sure what to do. I'm just trying to pick an email message form a given directory, there's no applicable host/username/password that makes sense for this operation.

I'm looking at how this works under the hood, and I think that the main issue is that main() tries to unconditionally read the configuration file, which makes it mandatory even in situations where it doesn't make sense. Perhaps lazy-reading the configuration when it is needed would help, but that sounds like a very non-trivial change.

Assigned to
1 year, 1 month ago
1 year, 1 month ago
No labels applied.

~bitfehler 1 year, 1 month ago

Interesting. Yes, this is indeed currently an unsupported use case. As a workaround, you can create a config file with an empty account:


The presence of an account is the only thing checked right now if you use a file system path.

For convenience, you could also do

local = "~/drafts"

and then you could simply run vmt pick . for the same result.

I'll change the title a bit to reflect that this is currently "intended" and consider this for future changes.

~whynothugo 1 year, 1 month ago*

An empty account:

> cat ~/.config/vomit/config.toml 

Doesn't seem to work either:

> vmt pick ~/drafts
10:17:29 [ERROR] failed to parse path '/home/hugo/drafts': path outside expected maildir: prefix not found

I'm not entirely sure what the error means; this directory contains cur, new and tmp.

Register here or Log in to comment, or comment via email.