Did something stupid, deleted libxml2

Hello dear Manjaro members,

as you read in the title:

I deleted libxml2 with -Rdd

As a result pacman is broken with

sudo pacman -Syu
pacman: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory

I tried installing it from source, which finally succeeded with

CFLAGS='-O2 -fno-semantic-interposition'  ./configure --prefix=/usr/

make check

sudo make install

Then I finally thought this might work. Just to be welcomed by the same problem. For which I thought I’d found a solution:

cd /usr/lib
ln -s libxml2.so.16.0.2 libxml2.so.2

and reloading shared libraries with

sudo ldconfig

but it still complained about libarchive.so.13 (as far as I remember)

The machine got rebooted (by accident) but I still got access via SSH.

Some help would be appreciated.

You may have the libxml2 package in /var/cache/pacman/pkg/

Can you install it from local with pacman -U?

1 Like

Nope, unfortunately not. This was the first thing I tried.

sudo pacman -U /var/cache/pacman/pkg/libxml2-2.13.8-1-x86_64.pkg.tar.zst
pacman: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory
1 Like

There is pacman-static for such cases. Search for it in the arch wiki and use it to do full sync and reinstall what’s missing.

5 Likes

unfortunately

~/build/pacman-static  master ✔                                                                                                             38d4h  ⍉
â–¶ LANG=C makepkg -sirc
==> Making package: pacman-static 7.0.0.r6.gc685ae6-17 (So 25 Mai 2025 12:37:19 CEST)
==> Checking runtime dependencies...
/usr/bin/pacman: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory
/usr/bin/pacman: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory

==> ERROR: An unknown error has occurred. Exiting...
==> Cleaning up...
[1]    61194 user-defined signal 1  LANG=C makepkg -sirc

Wait running now with

makepkg -ci

lets see

nearly

==> Verifying source file signatures with gpg...
    pacman git repo ... FAILED (unknown public key F99FFE0FEAE999BD)
    c-ares-1.34.5.tar.gz ... FAILED (unknown public key C1D15611B2E4720B)
    curl-8.13.0.tar.gz ... FAILED (unknown public key 5CC908FDB71E12C2)
    openssl-3.5.0.tar.gz ... FAILED (unknown public key 216094DFD0CB81EF)
    zlib-1.3.1.tar.gz ... FAILED (unknown public key 783FCD8E58BCAFBA)
    bzip2-1.0.8.tar.gz ... FAILED (unknown public key FC57E3CCACD99A78)
    zstd-1.5.7.tar.zst ... FAILED (unknown public key EF8FE99528B52FFD)
    libgpg-error-1.53.tar.bz2 ... FAILED (unknown public key E98E9B2D19C6C8BD)
    libassuan-3.0.0.tar.bz2 ... FAILED (unknown public key 528897B826403ADA)
    gpgme-1.24.2.tar.bz2 ... FAILED (unknown public key E98E9B2D19C6C8BD)
    libarchive-3.7.9.tar.xz ... FAILED (unknown public key 5848A18B8F14184B)
==> ERROR: One or more PGP signatures could not be verified!

can I skip those?

skipping PGP didn’t help either

~/build/pacman-static  master âś—                                                                                                            38d4h â—’
â–¶ LANG=C makepkg -ic --skippgpcheck
==> Making package: pacman-static 7.0.0.r6.gc685ae6-17 (So 25 Mai 2025 12:44:04 CEST)
==> Checking runtime dependencies...
/usr/bin/pacman: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory
==> Checking buildtime dependencies...
/usr/bin/pacman: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory
==> Retrieving sources...
  -> Updating pacman git repo...
  -> Found pacman-revertme-makepkg-remove-libdepends-and-libprovides.patch
  -> Found nghttp2-1.65.0.tar.xz
  -> Found c-ares-1.34.5.tar.gz
  -> Found c-ares-1.34.5.tar.gz.asc
  -> Found curl-8.13.0.tar.gz
  -> Found curl-8.13.0.tar.gz.asc
  -> Found openssl-3.5.0.tar.gz
  -> Found openssl-3.5.0.tar.gz.asc
  -> Found ca-dir.patch
  -> Found openssl-3.0.7-no-atomic.patch
  -> Found zlib-1.3.1.tar.gz
  -> Found zlib-1.3.1.tar.gz.asc
  -> Updating xz git repo...
  -> Found bzip2-1.0.8.tar.gz
  -> Found bzip2-1.0.8.tar.gz.sig
  -> Found zstd-1.5.7.tar.zst
  -> Found zstd-1.5.7.tar.zst.sig
  -> Found libgpg-error-1.53.tar.bz2
  -> Found libgpg-error-1.53.tar.bz2.sig
  -> Found libassuan-3.0.0.tar.bz2
  -> Found libassuan-3.0.0.tar.bz2.sig
  -> Found gpgme-1.24.2.tar.bz2
  -> Found gpgme-1.24.2.tar.bz2.sig
  -> Found libarchive-3.7.9.tar.xz
  -> Found libarchive-3.7.9.tar.xz.asc
==> WARNING: Skipping verification of source file PGP signatures.
==> Validating source files with sha512sums...
    pacman ... Passed
    pacman-revertme-makepkg-remove-libdepends-and-libprovides.patch ... Passed
    nghttp2-1.65.0.tar.xz ... Passed
    c-ares-1.34.5.tar.gz ... Passed
    c-ares-1.34.5.tar.gz.asc ... Skipped
    curl-8.13.0.tar.gz ... Passed
    curl-8.13.0.tar.gz.asc ... Skipped
    openssl-3.5.0.tar.gz ... Passed
    openssl-3.5.0.tar.gz.asc ... Skipped
    ca-dir.patch ... Passed
    openssl-3.0.7-no-atomic.patch ... Passed
    zlib-1.3.1.tar.gz ... Passed
    zlib-1.3.1.tar.gz.asc ... Skipped
    xz ... Passed
    bzip2-1.0.8.tar.gz ... Passed
    bzip2-1.0.8.tar.gz.sig ... Skipped
    zstd-1.5.7.tar.zst ... Passed
    zstd-1.5.7.tar.zst.sig ... Skipped
    libgpg-error-1.53.tar.bz2 ... Passed
    libgpg-error-1.53.tar.bz2.sig ... Skipped
    libassuan-3.0.0.tar.bz2 ... Passed
    libassuan-3.0.0.tar.bz2.sig ... Skipped
    gpgme-1.24.2.tar.bz2 ... Passed
    gpgme-1.24.2.tar.bz2.sig ... Skipped
    libarchive-3.7.9.tar.xz ... Passed
    libarchive-3.7.9.tar.xz.asc ... Skipped
==> Extracting sources...
  -> Creating working copy of pacman git repo...
Cloning into 'pacman'...
done.
Switched to a new branch 'makepkg'
  -> Extracting nghttp2-1.65.0.tar.xz with bsdtar
bsdtar: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory
==> ERROR: Failed to extract nghttp2-1.65.0.tar.xz
    Aborting...

Have you another Manjaro machine? If ssh works, scp should work too. Can you copy the lost file from the working one to the other (maybe it’s a silly idea, but it’s the first thing that comes to my mind)?

I compiled libxml2 from source and it is in /usr/lib/, but I think the right symlinks are not set. I found a solution on the Garuda forums, but that didn’t work either.

What if instead you open a page for e.g. pacman-static (in pacman archwiki) and actually read it? Did you think of that? Or are you just doing things randomly, because it certainly looks like it.

3 Likes

If it can help you, these are the symlinks in my computer:

lrwxrwxrwx 1 root root      13 may 13 16:31 libxml2.so -> libxml2.so.16
lrwxrwxrwx 1 root root      17 may 13 16:31 libxml2.so.16 -> libxml2.so.16.0.3
-rwxr-xr-x 1 root root 1297360 may 13 16:31 libxml2.so.16.0.3

Looking at timeshift backups, libxml2.so.2 was installed until the May 19 backup. Now it’s not in my system (and pacman works fine).

I followed these instructions:

Pacman Static

which resulted in

this

It still needs bsdtar to extract nghttp2, which in turn needs libxml2 again. Thus this is not a working solution either, unfortunately.

At first I tried pacman -U, did not work

Tried compiling from source, which worked partially, but the symlinks don’t seem to work

Tried the suggested approach of pacman-static, which is also not possible due to libxml2 missing.

No, you didn’t read it.

1 Like

Well, I read

The pinned comment and the PKGBUILD provides a way to directly download the binary, which can be used to reinstall pacman or to upgrade the entire system in case of partial upgrades.

I added the repo to pacman.conf

[pacman-static]
SigLevel = Required
Server = https://pkgbuild.com/~morganamilo/$repo/$arch

I downloaded the binary

I read the PKGBUILD, but couldn’t find anything really useful there. At least not obvious to me.

Copied the pacman-static binary to /usr/bin.

When I now run pacman-static as normal user it says that I don’t have enough rights. When I try sudo, it says the the command is not found.

EDIT: Reddit to the rescue. Couldn’t figure it out with the PKDBUILD. Though someone on Reddit had a similar issue



Download pacman-static binary from a trusted user here.

wget https://pkgbuild.com/~eschwartz/repo/x86_64-extracted/pacman-static

chmod +x ./pacman-static

sudo ./pacman-static -Syu

Use this with the correct repo mentioned on the AUR site! (Index of /~morganamilo/pacman-static/x86_64/bin/)

Now I could update the system and everything is working again!

Hi @mielouk,

See:

I previously helped someone else with a similar, if not the same issue.

2 Likes

I meant find the binary of the static from somewhere, like here for example
https://pkgbuild.com/~morganamilo/pacman-static/x86_64/bin/

2 Likes

Indeed I didn’t read it correctly. Sorry for the inconvenience!

Thanks to @abracadabra @Arrababiski and @Teo

Everything is fine now! Thanks for your patience and your help!

Have a very nice day, knowing you helped me immensely!

2 Likes

libxml2 is required by a number of other packages
see pacman -Qi libxml2 | grep Required for all the packages that are likely broken

pacman -R would have warned about possible dependency issues
pacman -Rd skips dependency version checks
pacman -Rdd skips all checks

IMO it would be simpler to use manjaro-chroot on a Live ISO to reinstall libxml2 repository

sudo pacman -S libxml2

but OP might need to use -dd option again to skip checks

It would be if pacman was working. Unfortunately it was broken because libxml2 was missing.