unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: "Peter J. Jones" <pjones@pmade.com>
To: notmuch@notmuchmail.org
Subject: notmuch insert: Cannot open Xapian database (0.34.1)
Date: Sat, 04 Dec 2021 11:30:39 -0700	[thread overview]
Message-ID: <87mtlg8bow.fsf@devalot.com> (raw)

I'm in the process of upgrading from notmuch 0.31.4 to 0.34.1 due to an
OS upgrade (NixOS 21.11).  I have tests that verify my mail
configuration (postfix, dovecot, notmuch, etc.) and they fail with
notmuch 0.34.1.  I've tracked it down to (what I believe to be) two
possible bugs.

First, with 0.31 you could call `notmuch insert` and it would create the
database if it didn't exist.  This appears to no longer work in 0.34:

```
[nix-shell:~/src/rc/mailrc]$ NOTMUCH_CONFIG=$(pwd)/config notmuch config get database.path
/home/pjones/src/rc/mailrc/maildir
[nix-shell:~/src/rc/mailrc]$ NOTMUCH_CONFIG=$(pwd)/config notmuch insert < <(echo foo)
Error: Cannot open database at /home/pjones/src/rc/mailrc/maildir/.notmuch: No such file or directory.
```

I can see in `notmuch.c` that the insert command doesn't have the
`NOTMUCH_COMMAND_DATABASE_CREATE` bit set, so this is the expected
behavior in 0.34 and was probably a bug in 0.31.  However, I would argue
that it's useful to create the database in this situation.

In my tests I bootstrap a new VM with an account that has no mail yet.
Then mail comes in via Dovecot which is handed off to `notmuch insert`,
which fails.  On my end I can fix the test by running `notmuch new`
before Dovecot calls `notmuch insert`.

The second issue is that if the `.notmuch` directory exists, but the
`.notmuch/xapian` directory doesn't, `notmuch new/insert` will fail:

```
[nix-shell:~/src/rc/mailrc]$ NOTMUCH_CONFIG=$(pwd)/config notmuch new
Found 0 total files (that's not much mail).
No new mail.
[nix-shell:~/src/rc/mailrc]$ rm -rf maildir/.notmuch/xapian
[nix-shell:~/src/rc/mailrc]$ NOTMUCH_CONFIG=$(pwd)/config notmuch new
Cannot open Xapian database at /home/pjones/src/rc/mailrc/maildir/.notmuch/xapian: Couldn't stat '/home/pjones/src/rc/mailrc/maildir/.notmuch/xapian'
```

The reason I get into this state is because I use Home Manager to manage
my configuration files and it creates `~/mail/.notmuch` so it can
install hook scripts.  Of course, this only happens on a brand new
setup, like in my test VM where Home Manager sets up my configuration
files first, then notmuch is run to test mail delivery and indexing.

This seemed to work in 0.31 (notmuch would just create a new database).

Would it be okay to change `notmuch_database_create_with_config` to
create a new database if `.notmuch` exists but `.notmuch/xapian`
doesn't?

Thanks!


-- 
Peter Jones

             reply	other threads:[~2021-12-04 18:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-04 18:30 Peter J. Jones [this message]
2021-12-04 19:01 ` notmuch insert: Cannot open Xapian database (0.34.1) David Bremner
2021-12-06 17:57   ` Peter J. Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mtlg8bow.fsf@devalot.com \
    --to=pjones@pmade.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).