Hi there,
when I try to use apk to update, add or remove applications I get the
following error:
ERROR: Unable to read database state: package file format error
ERROR: Failed to open apk database: package file format error
Strace shows a bit more info:
read(7, "C:Q1DAq8+0eVL2Ce+rsHzYHUPCmuEy8="..., 131072) = 131072
close(7) = 0
munmap(0x7f5d4fdd3000, 135168) = 0
writev(2, [{iov_base="", iov_len=0}, {iov_base="ERROR: ", iov_len=7}],
2) = 7 writev(2, [{iov_base="Unable to read database state: p"...,
iov_len=56}, {iov_base=NULL, iov_len=0}], 2) = 56 writev(2,
[{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2) = 1
Is there a way to recreate the database state file?
--
Kind regards,
Arjan Bouter
On Mon, 6 Jan 2025 18:56:51 +0100
Arjan Bouter <arjan@primeraholten.nl> wrote:
> when I try to use apk to update, add or remove applications I get the> following error:> > ERROR: Unable to read database state: package file format error> ERROR: Failed to open apk database: package file format error> > Strace shows a bit more info:> > read(7, "C:Q1DAq8+0eVL2Ce+rsHzYHUPCmuEy8="..., 131072) = 131072> close(7) = 0> munmap(0x7f5d4fdd3000, 135168) = 0> writev(2, [{iov_base="", iov_len=0}, {iov_base="ERROR: ", iov_len=7}],> 2) = 7 writev(2, [{iov_base="Unable to read database state: p"...,> iov_len=56}, {iov_base=NULL, iov_len=0}], 2) = 56 writev(2,> [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2) = 1> > Is there a way to recreate the database state file?
Generally only by reinstalling the system. Any idea how it went to this
state? Maybe its possible to fix it manually.
Timo
Not what I wanted to hear, lol.
after a bit of digging it looks like apk fails to read scripts.tar.
Removing the offending entry mentioned by strace, the first entry, makes it complain about the next entry
Renaming lets me "apk update" again, but apk throws "error: unabe to select packages", which makes sense.
from the looks of it, there is nothing strange about the contents of scripts.tar.
Is there any way to learn why and on what it trips?
As for the cause, an empty battery in my laptop during an update.
One of these I-m-sure-it's-plugged-in moments...
Thanks for the help,
Arjan
Timo Teras <timo.teras@iki.fi> schreef op 7 januari 2025 08:42:48 UTC:
>On Mon, 6 Jan 2025 18:56:51 +0100>Arjan Bouter <arjan@primeraholten.nl> wrote:>>> when I try to use apk to update, add or remove applications I get the>> following error:>> >> ERROR: Unable to read database state: package file format error>> ERROR: Failed to open apk database: package file format error>> >> Strace shows a bit more info:>> >> read(7, "C:Q1DAq8+0eVL2Ce+rsHzYHUPCmuEy8="..., 131072) = 131072>> close(7) = 0>> munmap(0x7f5d4fdd3000, 135168) = 0>> writev(2, [{iov_base="", iov_len=0}, {iov_base="ERROR: ", iov_len=7}],>> 2) = 7 writev(2, [{iov_base="Unable to read database state: p"...,>> iov_len=56}, {iov_base=NULL, iov_len=0}], 2) = 56 writev(2,>> [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2) = 1>> >> Is there a way to recreate the database state file?>>Generally only by reinstalling the system. Any idea how it went to this>state? Maybe its possible to fix it manually.>>Timo>
Hi,
You can also just wipe the database, and reinstall everything.
Something like:
mv /lib/apk/db /lib/apk/db.backup
mkdir /lib/apk/db
apk fix
Which should reinstall everything you had, unless you have packages
that are no longer available in the repositories.
Timo
On Tue, 07 Jan 2025 10:32:28 +0000
Arjan Bouter <arjan@primeraholten.nl> wrote:
> Not what I wanted to hear, lol.> > after a bit of digging it looks like apk fails to read scripts.tar.> Removing the offending entry mentioned by strace, the first entry,> makes it complain about the next entry Renaming lets me "apk update"> again, but apk throws "error: unabe to select packages", which makes> sense.> > from the looks of it, there is nothing strange about the contents of> scripts.tar. Is there any way to learn why and on what it trips?> > As for the cause, an empty battery in my laptop during an update.> One of these I-m-sure-it's-plugged-in moments...> > Thanks for the help,> Arjan> > > Timo Teras <timo.teras@iki.fi> schreef op 7 januari 2025 08:42:48 UTC:> >On Mon, 6 Jan 2025 18:56:51 +0100> >Arjan Bouter <arjan@primeraholten.nl> wrote:> > > >> when I try to use apk to update, add or remove applications I get> >> the following error:> >> > >> ERROR: Unable to read database state: package file format error> >> ERROR: Failed to open apk database: package file format error> >> > >> Strace shows a bit more info:> >> > >> read(7, "C:Q1DAq8+0eVL2Ce+rsHzYHUPCmuEy8="..., 131072) = 131072> >> close(7) = 0> >> munmap(0x7f5d4fdd3000, 135168) = 0> >> writev(2, [{iov_base="", iov_len=0}, {iov_base="ERROR: ",> >> iov_len=7}], 2) = 7 writev(2, [{iov_base="Unable to read database> >> state: p"..., iov_len=56}, {iov_base=NULL, iov_len=0}], 2) = 56> >> writev(2, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}],> >> 2) = 1> >> > >> Is there a way to recreate the database state file? > >> >Generally only by reinstalling the system. Any idea how it went to> >this state? Maybe its possible to fix it manually.> >> >Timo> >
It should, but doesn't.
That would be too easy.
The error is now: unable to select packages
It also complains about what appears to be the contents of /etc/apk/world which looks like /etc/resolv.conf
Timo Teras <timo.teras@iki.fi> schreef op 7 januari 2025 10:48:50 UTC:
>Hi,>>You can also just wipe the database, and reinstall everything.>Something like:>>mv /lib/apk/db /lib/apk/db.backup>mkdir /lib/apk/db>apk fix>>Which should reinstall everything you had, unless you have packages>that are no longer available in the repositories.>>Timo>>On Tue, 07 Jan 2025 10:32:28 +0000>Arjan Bouter <arjan@primeraholten.nl> wrote:>>> Not what I wanted to hear, lol.>> >> after a bit of digging it looks like apk fails to read scripts.tar.>> Removing the offending entry mentioned by strace, the first entry,>> makes it complain about the next entry Renaming lets me "apk update">> again, but apk throws "error: unabe to select packages", which makes>> sense.>> >> from the looks of it, there is nothing strange about the contents of>> scripts.tar. Is there any way to learn why and on what it trips?>> >> As for the cause, an empty battery in my laptop during an update.>> One of these I-m-sure-it's-plugged-in moments...>> >> Thanks for the help,>> Arjan>> >> >> Timo Teras <timo.teras@iki.fi> schreef op 7 januari 2025 08:42:48 UTC:>> >On Mon, 6 Jan 2025 18:56:51 +0100>> >Arjan Bouter <arjan@primeraholten.nl> wrote:>> > >> >> when I try to use apk to update, add or remove applications I get>> >> the following error:>> >> >> >> ERROR: Unable to read database state: package file format error>> >> ERROR: Failed to open apk database: package file format error>> >> >> >> Strace shows a bit more info:>> >> >> >> read(7, "C:Q1DAq8+0eVL2Ce+rsHzYHUPCmuEy8="..., 131072) = 131072>> >> close(7) = 0>> >> munmap(0x7f5d4fdd3000, 135168) = 0>> >> writev(2, [{iov_base="", iov_len=0}, {iov_base="ERROR: ",>> >> iov_len=7}], 2) = 7 writev(2, [{iov_base="Unable to read database>> >> state: p"..., iov_len=56}, {iov_base=NULL, iov_len=0}], 2) = 56>> >> writev(2, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}],>> >> 2) = 1>> >> >> >> Is there a way to recreate the database state file? >> >>> >Generally only by reinstalling the system. Any idea how it went to>> >this state? Maybe its possible to fix it manually.>> >>> >Timo>> > >
Would you mind sharing the contents of /etc/apk/world?
> It should, but doesn't.> That would be too easy.>> The error is now: unable to select packages > It also complains about what appears to be the contents of /etc/apk/world which looks like /etc/resolv.conf>>> Timo Teras <timo.teras@iki.fi> schreef op 7 januari 2025 10:48:50 UTC:> >Hi,> >> >You can also just wipe the database, and reinstall everything.> >Something like:> >> >mv /lib/apk/db /lib/apk/db.backup> >mkdir /lib/apk/db> >apk fix> >> >Which should reinstall everything you had, unless you have packages> >that are no longer available in the repositories.> >> >Timo> >> >On Tue, 07 Jan 2025 10:32:28 +0000> >Arjan Bouter <arjan@primeraholten.nl> wrote:> >> >> Not what I wanted to hear, lol.> >> > >> after a bit of digging it looks like apk fails to read scripts.tar.> >> Removing the offending entry mentioned by strace, the first entry,> >> makes it complain about the next entry Renaming lets me "apk update"> >> again, but apk throws "error: unabe to select packages", which makes> >> sense.> >> > >> from the looks of it, there is nothing strange about the contents of> >> scripts.tar. Is there any way to learn why and on what it trips?> >> > >> As for the cause, an empty battery in my laptop during an update.> >> One of these I-m-sure-it's-plugged-in moments...> >> > >> Thanks for the help,> >> Arjan> >> > >> > >> Timo Teras <timo.teras@iki.fi> schreef op 7 januari 2025 08:42:48 UTC:> >> >On Mon, 6 Jan 2025 18:56:51 +0100> >> >Arjan Bouter <arjan@primeraholten.nl> wrote:> >> > > >> >> when I try to use apk to update, add or remove applications I get> >> >> the following error:> >> >> > >> >> ERROR: Unable to read database state: package file format error> >> >> ERROR: Failed to open apk database: package file format error> >> >> > >> >> Strace shows a bit more info:> >> >> > >> >> read(7, "C:Q1DAq8+0eVL2Ce+rsHzYHUPCmuEy8="..., 131072) = 131072> >> >> close(7) = 0> >> >> munmap(0x7f5d4fdd3000, 135168) = 0> >> >> writev(2, [{iov_base="", iov_len=0}, {iov_base="ERROR: ",> >> >> iov_len=7}], 2) = 7 writev(2, [{iov_base="Unable to read database> >> >> state: p"..., iov_len=56}, {iov_base=NULL, iov_len=0}], 2) = 56> >> >> writev(2, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}],> >> >> 2) = 1> >> >> > >> >> Is there a way to recreate the database state file? > >> >> >> >Generally only by reinstalling the system. Any idea how it went to> >> >this state? Maybe its possible to fix it manually.> >> >> >> >Timo> >> > > >