Can't open mu4e when Emacs is running as daemon (systemd)

6 views
Skip to first unread message

antis...@city17.xyz

unread,
Jul 2, 2025, 4:31:58 PMJul 2
to mu-discuss

I'm running an experiment, I'm trying to run Emacs as a systemd service. I then connect to the
service with `emacsclient -t`.
I experience consistently an error when opening mu4e. `mu4e-debug` is `t` but I can't get enough
info to understand what the problem is.
When running emacs not-as-service everything just works fine

The *mu4e-log* looks like:

2025-07-02 22:04:24.284 * invoking '/usr/bin/mu' with parameters 'server'
2025-07-02 22:04:24.285 -> (ping)
2025-07-02 22:04:24.285 -> (data :kind maildirs)
2025-07-02 22:04:24.286 -> (queries :queries ("flag:unread AND (maildir:/domain.org/me/Inbox OR
maildir:/domain.org/me2/Inbox)" ... ))
2025-07-02 22:04:24.286 -> (contacts :personal nil :after "2018-01-01" :tstamp "0" :maxnum nil)
2025-07-02 22:04:24.296 * Received 70 byte(s)
2025-07-02 22:04:24.298 * famous last words from server: 'error: failed to open database
hint: Try (re)creating using `mu init'
'

I think the "mu init" hint is misleading, the database is not corrupted. I think it's trying to tell
me that it can't find some stuff.

The system log is not very detailed as well:

$ journalctl -f --user --unit emacs
Jul 02 22:04:24 host mu[12923]: logging initialized; debug: no, stdout/stderr: no
Jul 02 22:04:24 host mu[12923]: mu finishing with error: <failed to open database (121:1)>
Jul 02 22:04:24 host mu[12923]: hint: Try (re)creating using `mu init'

Can I increase the logging of `mu` and see what does actually "failed to open database" mean?

How can I tell mu4e to "please invoke mu with maximum debugging and logging?"

Thanks

sam kleinman

unread,
Jul 2, 2025, 5:12:06 PMJul 2
to antisocial via mu-discuss

On Wednesday, July 02 2025, 22:31:47, antisocial via mu-discuss wrote:

> I'm running an experiment, I'm trying to run Emacs as a systemd
> service. I then connect to the service with `emacsclient -t`.
> I experience consistently an error when opening mu4e. `mu4e-debug` is
> `t` but I can't get enough info to understand what the problem is.
> When running emacs not-as-service everything just works fine

I've been running into this recently (new versions of emacs probably correlated based on my memory of the timing.)

Running "killall mu" seems to fix it (for me!). Thanks for pointing this out though! I had been thinking I had made some unrelated change that had screwed this up. At least now I don't need to dig into that. Hopefully, other folks here will have a better way to address.

In the mean time, I've been running emacs as a systemd service for years. Welcome to the club.

Cheers,
sam

Joost Kremers

unread,
Jul 2, 2025, 5:31:21 PMJul 2
to antisocial via mu-discuss
On Wed, Jul 02 2025, antisocial via mu-discuss wrote:
> I'm running an experiment, I'm trying to run Emacs as a systemd service. I
> then connect to the service with `emacsclient -t`.
> I experience consistently an error when opening mu4e. `mu4e-debug` is `t`

There's also `mu4e-mu-debug`, which is probably more useful, because your
problem appears to be with the mu server, not with mu4e.

> but I can't get enough info to understand what the problem is.
> When running emacs not-as-service everything just works fine

That kinda suggests that it may be some permission issue, or mu being run
as the wrong user.

> The *mu4e-log* looks like:

You'll probably want to look at the mu logs, which can be in one of a few
locations. See `man mu`.

> 2025-07-02 22:04:24.284 * invoking '/usr/bin/mu' with parameters 'server'
> 2025-07-02 22:04:24.285 -> (ping)
> 2025-07-02 22:04:24.285 -> (data :kind maildirs)
> 2025-07-02 22:04:24.286 -> (queries :queries ("flag:unread AND
> (maildir:/domain.org/me/Inbox OR maildir:/domain.org/me2/Inbox)" ... ))
> 2025-07-02 22:04:24.286 -> (contacts :personal nil :after "2018-01-01"
> :tstamp "0" :maxnum nil)
> 2025-07-02 22:04:24.296 * Received 70 byte(s)
> 2025-07-02 22:04:24.298 * famous last words from server: 'error: failed to open database
> hint: Try (re)creating using `mu init'
> '
>
> I think the "mu init" hint is misleading, the database is not corrupted. I
> think it's trying to tell me that it can't find some stuff.
>
> The system log is not very detailed as well:
>
> $ journalctl -f --user --unit emacs
> Jul 02 22:04:24 host mu[12923]: logging initialized; debug: no, stdout/stderr: no
> Jul 02 22:04:24 host mu[12923]: mu finishing with error: <failed to open database (121:1)>
> Jul 02 22:04:24 host mu[12923]: hint: Try (re)creating using `mu init'
>
> Can I increase the logging of `mu` and see what does actually "failed to
> open database" mean?

I assume `mu4e-mu-debug` will do that.

HTH

--
Joost Kremers
Life has its moments

jman

unread,
Jul 3, 2025, 11:31:28 AMJul 3
to Joost Kremers, antisocial via mu-discuss
Joost Kremers <joostk...@fastmail.fm> writes:

> On Wed, Jul 02 2025, antisocial via mu-discuss wrote:
>> I'm running an experiment, I'm trying to run Emacs as a systemd service. I
>> then connect to the service with `emacsclient -t`.
>> I experience consistently an error when opening mu4e. `mu4e-debug` is `t`
>
> There's also `mu4e-mu-debug`, which is probably more useful, because your
> problem appears to be with the mu server, not with mu4e.

I've tried enabling that as well but the logging level didn't change in that line, I see the same
"quantity" of logging with `mu4e-mu-debug` nil or t

Maybe it would be helpful to increase the logging in case of DatabaseNotFoundError[0].

> That kinda suggests that it may be some permission issue, or mu being run
> as the wrong user.

Close! I checked the mu-server code[0] and the "failed to open database" string is logging a
"DatabaseNotFoundError", which is a slightly better hint. I fixed my configuration and solved the
problem.

Anyway, thanks for the help!

[0] https://github.com/djcb/mu/blob/3f53e4b439dada77c76d5fcd707ec88f3cbbe489/lib/mu-xapian-db.hh#L96
Reply all
Reply to author
Forward
0 new messages