pimutils / vdirsyncer

📇 Synchronize calendars and contacts.
https://vdirsyncer.pimutils.org/
Other
1.55k stars 160 forks source link

Unknown error unable to open database file #1113

Open balki opened 8 months ago

balki commented 8 months ago

I was getting below error when trying to sync. vdirsyncer -v DEBUG sync

debug: Already normalized: '/balki/12c9dbdc-3ce6-b970-e9a1-c5c7d234f72a/bd5de934-3aca-4863-bcd0-7d82eb11d189.ics'
error: Unknown error occurred for foobar_calendar/12c9dbdc-3ce6-b970-e9a1-c5c7d234f72a: unable to open database file
error: Use `-vdebug` to see the full traceback.
debug:   File "/usr/lib/python3.11/site-packages/vdirsyncer/cli/tasks.py", line 72, in sync_collection
debug:     await sync.sync(
debug:   File "/usr/lib/python3.11/site-packages/vdirsyncer/sync/__init__.py", line 142, in sync
debug:     with status.transaction():
debug:   File "/usr/lib/python3.11/contextlib.py", line 144, in __exit__
debug:     next(self.gen)
debug:   File "/usr/lib/python3.11/site-packages/vdirsyncer/sync/status.py", line 188, in transaction
debug:     self._c.execute("INSERT INTO status " "SELECT * FROM new_status")

This happens because sqlite library tries to write to a temporary file in /var/tmp/ when trying to execute the above insert statement. In my system (it is a systemd container), /var/tmp/ folder is not writable by regular user even though the permissions are ok. No idea how to fix that (something to do with user namespace).

⬢ [OCI] ❯ mkdir /var/tmp/etilqs_ac938b9762164c3a
mkdir: cannot create directory ‘/var/tmp/etilqs_ac938b9762164c3a’: Value too large for defined data type

Workaround

SQLITE_TMPDIR=/tmp vdirsyncer sync

This tells sqlite to use /tmp/ instead of /var/tmp and it works fine.


This is not a bug in vdirsyncer but just a quirk with my system and sqlite library. Adding here so it will be helpful for anyone who faces it as it was not easy to debug.

May be good to add a note in 'Trouble shooting' section of the docs.

WhyNotHugo commented 8 months ago

This sounds like a bug in how sqlite is configure when it is built. It might be worth reporting to your distribution; if /var/tmp doesn't exist but sqlite tries to use that by default, it should definitely be fixed.