Bug 411093 - Unable to start Akonadi: Could not open required defaults file
Summary: Unable to start Akonadi: Could not open required defaults file
Status: RESOLVED DOWNSTREAM
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: server (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR major
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 411417 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-08-20 08:51 UTC by Daniel Kraus
Modified: 2023-04-28 15:39 UTC (History)
20 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Kraus 2019-08-20 08:51:48 UTC
SUMMARY


STEPS TO REPRODUCE
1. Upgrade KDE neon 5.16 with KDE Applications 19.08
2. Attempt to start Akonadi

OBSERVED RESULT

Akonadi will not start.

```
$ akonadictl start
Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
org.kde.pim.akonadiserver: Starting up the Akonadi Server...
org.kde.pim.akonadiserver: database server stopped unexpectedly
org.kde.pim.akonadiserver: Database process exited unexpectedly during initial connection!
org.kde.pim.akonadiserver: executable: "/usr/sbin/mysqld-akonadi"
org.kde.pim.akonadiserver: arguments: ("--defaults-file=/home/USER/.local/share/akonadi/mysql.conf", "--datadir=/home/daniel/.local/share/akonadi/db_data/", "--socket=/run/user/1000/akonadi/mysql.socket", "--pid-file=/run/user/1000/akonadi/mysql.pid")
org.kde.pim.akonadiserver: stdout: ""
org.kde.pim.akonadiserver: stderr: "mysqld-akonadi: [ERROR] Could not open required defaults file: /home/USER/.local/share/akonadi/mysql.conf\nmysqld-akonadi: [ERROR] Fatal error in defaults handling. Program aborted!\n"
org.kde.pim.akonadiserver: exit code: 1
org.kde.pim.akonadiserver: process error: "Unknown error"
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/run/user/1000/akonadi/mysql.socket' (2)'
Check that mysqld is running and that the socket: '/run/user/1000/akonadi/mysql.socket' exists!
org.kde.pim.akonadiserver: Failed to remove runtime connection config file
org.kde.pim.akonadiserver: Shutting down AkonadiServer...
org.kde.pim.akonadicontrol: Application '/usr/bin/akonadiserver' exited normally...
```

What I already attempted to do: Uninstall/reinstall Akonadi; move /home/USER/.local/share/akonadi out of the way; change AppArmor settings (see forum thread linked below).


EXPECTED RESULT

Akonadi should just start (as it did for years prior to upgrading to KDE Applications 19.08).

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE neon 5.16 User Edition
(available in About System)
KDE Plasma Version: 5.16.4
KDE Frameworks Version: 5.61.0
Qt Version: 5.12.3

ADDITIONAL INFORMATION

See related forum thread: https://forum.kde.org/viewtopic.php?f=215&t=162053
Comment 1 Daniel Kraus 2019-08-20 12:24:27 UTC
NB: I replaced my original user name with 'USER' in this report (albeit not in all places...).
Comment 2 Dan 2019-08-20 15:53:56 UTC
Same error (and same system info), and would just like to add an observation or two, in case they're helpful.

First, when following these directions:

https://docs.kde.org/stable5/en/pim/kmail2/clean-start-after-a-failed-migration.html

the process fails with the same error report, and only creates some of the files it should.

/etc/apparmor.d/usr.sbin.mysqld-akonadi features a line added in a previous bugfix to allow for creation of mysql lockfile (i think?):

 owner /run/user/*/akonadi/default/* wr,

but my output shows an argument using a different directory:

"--socket=/run/user/1000/akonadi/mysql.socket" 

and akonadiserverrc uses the same directory:

[QMYSQL]
Host=
Name=akonadi
Options="UNIX_SOCKET=/run/user/1000/akonadi/mysql.socket"
ServerPath=/usr/sbin/mysqld-akonadi
StartServer=true

...after the clean start process, /run/user/1000/akonadi/ is empty.

Thanks!
Comment 3 Raphael 2019-08-20 19:29:16 UTC
I think the second error message about connection via socket to local server results from a fallback after start of a local instance of mysql failed. The main problem is access to /home/${USER}/.local/share/akonadi/mysql.conf.
Comment 4 Daniel Kraus 2019-08-20 19:38:36 UTC
I `tail -f`ed /var/syslog and issued akonadictl start:

Aug 20 21:34:26 localhost kernel: [63166.278573] audit: type=1400 audit(1566329666.867:197): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=22974 comm="mysqld-akonadi" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Aug 20 21:34:26 localhost kernel: [63166.295499] audit: type=1400 audit(1566329666.883:198): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=22975 comm="mysqld-akonadi" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Aug 20 21:34:26 localhost kernel: [63166.297604] audit: type=1400 audit(1566329666.883:199): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/home/$(USER)/.local/share/akonadi/mysql.conf" pid=22975 comm="mysqld-akonadi" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000

As mentioned above, I did try to relax AppArmor rules as per forum suggestions. Possibly the solution is very simple, but I'm not familiar with the AppArmor DSL. Any help would be appreciated.
Comment 5 Daniel Kraus 2019-08-21 08:23:25 UTC
The problem was solved by tearing down AppArmor, then restarting it.

```
sudo service apparmor teardown
sudo service apparmor start
```

(NB: `systemctl` cannot handle the `teardown` task, and `stop` won't do it)
Comment 6 Dan 2019-08-21 23:40:36 UTC
So, this worked for me, but after rebooting my machine, akonadi did not start, and a manual start with akonadictl resulted in the same old failure and error messages, and I had to tear down and restart apparmor again. I assume I'll have to do this every time I start my desktop or laptop. 

So, this is an ugly work-around, not really a solution. Any idea how to get apparmor to permit access to the required files permanently?
Comment 7 Alexander Zhigalin 2019-10-14 16:47:55 UTC
The worksforme status is for bugs which can't be reproduced.
Comment 8 Erasmo Caponio 2019-10-26 13:16:58 UTC
Same problem here. I am running kde neon user edition, plasma version 5.17.1
Comment 9 Erasmo Caponio 2019-10-26 13:22:40 UTC
*** Bug 411417 has been marked as a duplicate of this bug. ***
Comment 10 Dan 2019-11-01 02:35:54 UTC
This thread

https://forum.kde.org/viewtopic.php?f=215&t=162239&hilit=akonadi+won%27t+start

points out that it appears a dev accidentally has pasted a newline into a file path, and that maybe this could be causing the problem:

org.kde.pim.akonadiserver: stderr: "mysqld-akonadi: [ERROR] Could not open required defaults file: /home/andrea/.local/share/akonadi/mysql.conf\nmysqld-akonadi: [ERROR] Fatal error in defaults handling. Program aborted!\n"
Comment 11 Subin 2019-12-17 17:20:26 UTC
I faced the same bug when I upgraded my KDE neon yesterday. Is there a workaround please ?

Can't access KMail now...
Comment 12 Dan 2019-12-17 19:53:11 UTC
(In reply to Subin from comment #11)
> I faced the same bug when I upgraded my KDE neon yesterday. Is there a
> workaround please ?
> 
> Can't access KMail now...

There's an apparmor workaround detailed here, although if I recall I got a lot of apparmor errors about missing files that I needed to create before it would work that I don't entirely remember and didn't document, and my Kmail isn't quite doing everything right... but, it mostly works fine.

https://forum.kde.org/viewtopic.php?f=215&t=162053
Comment 13 Erasmo Caponio 2019-12-18 16:09:14 UTC
(In reply to Dan from comment #12)

After last upgrade of KDE Neon, also that workaround does not work anymore on my system. Not only this bug is still there after several months,  it has become worse too   

> (In reply to Subin from comment #11)
> > I faced the same bug when I upgraded my KDE neon yesterday. Is there a
> > workaround please ?
> > 
> > Can't access KMail now...
> 
> There's an apparmor workaround detailed here, although if I recall I got a
> lot of apparmor errors about missing files that I needed to create before it
> would work that I don't entirely remember and didn't document, and my Kmail
> isn't quite doing everything right... but, it mostly works fine.
> 
> https://forum.kde.org/viewtopic.php?f=215&t=162053
Comment 14 Erasmo Caponio 2019-12-21 11:35:33 UTC
After removing Snapd from my system (that honestly I find quite useless and full of problems) everything works fine with Apparmor. Now Akonadi starts without any problem
Comment 15 Sandro Knauß 2019-12-24 18:36:33 UTC
this is KDE Neon bug. They don't have merged the changes done by Debian, like removing akonadi-mysql completly in d/rules.
Comment 16 Subin 2019-12-30 17:55:36 UTC
(In reply to Erasmo Caponio from comment #14)
> After removing Snapd from my system (that honestly I find quite useless and
> full of problems) everything works fine with Apparmor. Now Akonadi starts
> without any problem

Is snapd really related to this ? This is a KDE Neon issue. Any confirmed workarounds to fix it ? I can't access KMail :(
Comment 17 Aldo Latino 2020-01-01 09:24:55 UTC
I can confirm that this is a KDE Neon bug. Some days ago I had major problems with my nVidia card and KDE Neon, so I switched to Kubuntu 18.04.3 and Akonadi works without any problem.

Anyway, even if KDE Neon developers resolve this issue, there is another bigger problem with Kontact suite, which has been blocked by Google. Here is the bug: https://bugs.kde.org/show_bug.cgi?id=404990
Comment 18 Erasmo Caponio 2020-01-01 15:43:57 UTC
I don't know if it is a neon bug or not
anyway any comparison with other distribution should be done with the same software installed because, as I wrote above, on my system, purging snapd fixrd the issue. 
Regarding the problem with Google accounts, it is enough to allow less secure app to get again access with Akonadi 

(In reply to aldolat from comment #17)
> I can confirm that this is a KDE Neon bug. Some days ago I had major
> problems with my nVidia card and KDE Neon, so I switched to Kubuntu 18.04.3
> and Akonadi works without any problem.
> 
> Anyway, even if KDE Neon developers resolve this issue, there is another
> bigger problem with Kontact suite, which has been blocked by Google. Here is
> the bug: https://bugs.kde.org/show_bug.cgi?id=404990
Comment 19 Aldo Latino 2020-01-01 16:19:09 UTC
(In reply to Erasmo Caponio from comment #18)
> Regarding the problem with Google accounts, it is enough to allow less
> secure app to get again access with Akonadi 

I have the 2FA activated, so Google doesn't allow less secure apps to gain access to my account. I could use a specific app for Kontact/Kmail but, when a Gmail server is used, Kmail disables password in favour of Oauth. And Oauth is currently not usable as I wrote before, because Kontact is not authorized to access. For this reason I can't access my Gmail account using Kontact.
Comment 20 Subin 2020-02-28 17:42:02 UTC
This bug still exists in the Plasma 5.18 update and KDE Neon update.
Comment 21 Subin 2020-02-29 15:04:01 UTC
I was able to start Akonadi by disabling Apparmor for mysql :

sudo aa-disable mysqld

This was mentioned here : https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=921987
Comment 22 Dmitry 2020-02-29 15:36:39 UTC
As for me, I was able to start Akonadi with:

rm -r ~/.config/akonadi
rm -r ~/.local/share/akonadi
sudo apt update
sudo apt install akonadi* --reinstall
sudo reboot now

But I had to recreate the imap accounts in Kmail after it.
Comment 23 Er 2020-04-09 21:44:20 UTC
Have the same problem.
When install clean system akonadi works good and kate work.
When I install mysqlserver akonadi crashed.
Deleting mysqlserver does not solve problem.

Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.4
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.5
Kernel Version: 5.4.0-21-generic
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-7700HQ CPU @ 2.80GHz
Memory: 15,5 ГиБ
Comment 24 GK 2020-05-04 06:15:07 UTC
Same here since an update in Kubuntu 18.04. I moved to 19.10 and then a few days ago to 20.04, but got the same errors while launching akonadictl from terminal:

QUOTE
rg.kde.pim.akonadiserver: Starting up the Akonadi Server...
mysqld-akonadi: [ERROR] Failed to open required defaults file: /home/gkourtev/
mysqld-akonadi: [ERROR] Fatal error in defaults handling. Program aborted!
org.kde.pim.akonadiserver: database server stopped unexpectedly
org.kde.pim.akonadiserver: Database process exited unexpectedly during initial connection!
org.kde.pim.akonadiserver: executable: "/usr/sbin/mysqld-akonadi"
org.kde.pim.akonadiserver: arguments: ("--defaults-file=/home/gkourtev/.local/share/akonadi/mysql.conf", "--datadir=/home/gkourtev/.local/share/akonadi/db_data/", "--socket=/run/user/1000/akonadi/mysql.socket", "--pid-file=/run/user/1000/akonadi/mysql.pid")
org.kde.pim.akonadiserver: stdout: ""
org.kde.pim.akonadiserver: stderr: "mysqld-akonadi: [ERROR] Failed to open required defaults file: /home/gkourtev/.local/share/akonadi/mysql.conf\nmysqld-akonadi: [ERROR] Fatal error in defaults handling. Program aborted!\n"
org.kde.pim.akonadiserver: exit code: 1
org.kde.pim.akonadiserver: process error: "Unknown error"
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/run/user/1000/akonadi/mysql.socket' (2)'
Check that mysqld is running and that the socket: '/run/user/1000/akonadi/mysql.socket' exists!
org.kde.pim.akonadiserver: Failed to remove runtime connection config file
org.kde.pim.akonadiserver: Shutting down AkonadiServer...
org.kde.pim.akonadicontrol: Application '/usr/bin/akonadiserver' exited normally...
UNQUOTE

Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.4
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
Kernel Version: 5.4.0-28-generic
OS Type: 64-bit
Processors: 4 × Intel® Core™ i7-6500U CPU @ 2.50GHz
Memory: 15,5 GiB of RAM
Comment 25 Alexander Zhigalin 2020-05-04 08:31:24 UTC
(In reply to GK from comment #24)
> Same here since an update in Kubuntu 18.04. I moved to 19.10 and then a few
> days ago to 20.04, but got the same errors while launching akonadictl from
> terminal:
> 
> QUOTE
> rg.kde.pim.akonadiserver: Starting up the Akonadi Server...
> mysqld-akonadi: [ERROR] Failed to open required defaults file:
> /home/gkourtev/
> mysqld-akonadi: [ERROR] Fatal error in defaults handling. Program aborted!
> org.kde.pim.akonadiserver: database server stopped unexpectedly
> org.kde.pim.akonadiserver: Database process exited unexpectedly during
> initial connection!
> org.kde.pim.akonadiserver: executable: "/usr/sbin/mysqld-akonadi"
> org.kde.pim.akonadiserver: arguments:
> ("--defaults-file=/home/gkourtev/.local/share/akonadi/mysql.conf",
> "--datadir=/home/gkourtev/.local/share/akonadi/db_data/",
> "--socket=/run/user/1000/akonadi/mysql.socket",
> "--pid-file=/run/user/1000/akonadi/mysql.pid")
> org.kde.pim.akonadiserver: stdout: ""
> org.kde.pim.akonadiserver: stderr: "mysqld-akonadi: [ERROR] Failed to open
> required defaults file:
> /home/gkourtev/.local/share/akonadi/mysql.conf\nmysqld-akonadi: [ERROR]
> Fatal error in defaults handling. Program aborted!\n"
> org.kde.pim.akonadiserver: exit code: 1
> org.kde.pim.akonadiserver: process error: "Unknown error"
> mysqladmin: connect to server at 'localhost' failed
> error: 'Can't connect to local MySQL server through socket
> '/run/user/1000/akonadi/mysql.socket' (2)'
> Check that mysqld is running and that the socket:
> '/run/user/1000/akonadi/mysql.socket' exists!
> org.kde.pim.akonadiserver: Failed to remove runtime connection config file
> org.kde.pim.akonadiserver: Shutting down AkonadiServer...
> org.kde.pim.akonadicontrol: Application '/usr/bin/akonadiserver' exited
> normally...
> UNQUOTE
> 
> Operating System: Kubuntu 20.04
> KDE Plasma Version: 5.18.4
> KDE Frameworks Version: 5.68.0
> Qt Version: 5.12.8
> Kernel Version: 5.4.0-28-generic
> OS Type: 64-bit
> Processors: 4 × Intel® Core™ i7-6500U CPU @ 2.50GHz
> Memory: 15,5 GiB of RAM

Can you try to disable AppArmor and start it?
It helped for me when I had this bug.
Seems to be something wrong with the AA policy which causes mysqld-akonadi to be unable to read it's configuration.

Anyway, I'm changing this bug product because it's not really Neon-specific.
Comment 26 GK 2020-05-04 13:10:26 UTC
Hi,
Yes I tried to disable, but does not change anything.
Comment 27 Sandro Knauß 2020-05-04 20:36:32 UTC
@GK: please report this issue at kubuntu directly as this is properly a packaging issue. Otherwise this may be a unrelated issue. 

Also for the people having this issue with Neon please report directly on Neon, I am quite sure, that the neon people are NOT aware of this issue.
Comment 28 Steffen Michalek 2020-05-09 20:48:58 UTC
1) updated Kubuntu 19-10 -> 20.04 yesterday, problems with kmail & kontact: akonadi not running
2) > akonadictl start   - didn't work, error "Could not open required defaults file: /home/NNN/.local/share/akonadi/mysql.conf"[...]
3) started apparmor notification: > started aa-notify -p   saw problem with mysql
4) searched more, found: https://askubuntu.com/questions/1144497/how-to-disable-apparmor-for-mysql , followed instructions:
5) > sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
   > sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
6) > akonadictl start    - works! :-)
(in kontact, the calendars were no longer chosen, I had to reactivate the checkboxes,
kmail works)

If I understand correctly, apparmor is now not longer protecting mysql.
I have to re-activate, once another solution is found: same askubuntu...
Comment 29 Poborskiii 2020-05-10 15:14:53 UTC
Better is disabling only akonadiserver instead of whole mysql:
sudo ln -s /etc/apparmor.d/usr.bin.akonadiserver /etc/apparmor.d/disable/

But in my case this file was missing. I had to copy from https://cgit.kde.org/akonadi.git/tree/apparmor/usr.bin.akonadiserver

Also if have KDEAPPS older than 19.12.2 you should update /etc/apparmor.d/mysqld_akonadi to latest from https://cgit.kde.org/akonadi.git/tree/apparmor/mysqld_akonadi (because patch)

This (for me working) solution became from https://bugs.kde.org/show_bug.cgi?id=416016
Comment 30 Andy Goossens 2020-05-10 16:33:11 UTC
Someone already created an issue for this on Launchpad:
https://bugs.launchpad.net/ubuntu/+source/akonadi/+bug/1873087

Following the instructions in the ticket description has fixed the issue for me.
Comment 31 Ahmad Samir 2020-08-16 14:29:14 UTC
So basically this means, misconfigured AppArmor rules prevent mysqld-akonadi from reading ~/.local/share/akonadi/mysql.conf, which causes this bug? if so, then it's a downstream issue in Kubuntu, and has to be fixed there, IIUC.
Comment 32 Erasmo Caponio 2020-08-16 14:45:29 UTC
This bug seems solved in kde neon based on Ubuntu 20.04 (at least on my upgraded system). Removing and reinstalling apparmor and snapd may help (Anyway I still have snapd removed)
Comment 33 Aldo Latino 2020-08-16 19:40:58 UTC
After many tests (either on my work computer and in some VirtualBox machines) I discovered that this problem happens to me when I install the package mysql-server which removes some Akonadi related packages[1]. In other words, if I don't install mysql-server, Akonadi works fine. After the installation of mysql-server, Akonadi stops working.

In this situation, since I need a LAMP server on my machine, I have to perform some actions in order to make Akonadi work with mysql-server.

[1]
MySQL is correctly installed but these are some of the lines printed during the installation process:
Preconfiguring packages ...
dpkg: mariadb-client-core-10.3: dependency problems, but removing anyway as you requested:
 akonadi-backend-mysql depends on mariadb-client-core-10.3 | virtual-mysql-client-core; however:
  Package mariadb-client-core-10.3 is to be removed.
  Package virtual-mysql-client-core is not installed.
  Package mariadb-client-core-10.3 which provides virtual-mysql-client-core is to be removed.
Comment 34 Ahmad Samir 2020-08-16 19:59:50 UTC
@Aldo: this looks like a downstream packaging issue, I suggest you file a bug report in your distro's bug tracker.