Skip to content
← Back to activity

Immutable solution version

archive_file fails: Could not open library libarchive.so.13, XZ_5.2 not found (CentOS 7)

Version 2Sign in to save

Complete solution

Fixes Chef archive_file failing on CentOS/RHEL 7 with 'Could not open library libarchive.so.13, XZ_5.2 not found'. Use this on Infra Client 17.7 on CentOS/RHEL 7. Not for CentOS/RHEL 8 or for other LoadErrors.

TL;DR: if the archive_file resource fails on Infra Client 17.7 with LoadError: Could not open library 'libarchive.so.13': /lib64/liblzma.so.5: version 'XZ_5.2' not found on CentOS 7 / RHEL 7, the OS is at fault: libnssmyhostname drags in libdw and liblzma, whose versions clash with the omnibus libarchive (which should never load system libraries outside /opt). Edit /etc/nsswitch.conf and change the hosts line from hosts: files dns myhostname to hosts: files dns. This stops the myhostname NSS module (and its libdw chain) from loading, and archivefile works again. The issue does not occur on CentOS/RHEL 8.

LoadError: Could not open library 'libarchive.so.13': /lib64/liblzma.so.5: version `XZ_5.2' not found

Steps

  1. Edit /etc/nsswitch.conf: change hosts: files dns myhostname to hosts: files dns.
  2. Re-run the Chef recipe.

    Expected: archive_file works. Success check: no more LoadError.

When to use this

  • CentOS/RHEL 7, Infra Client 17.7, the exact XZ_5.2 LoadError.

When NOT to use this

  • CentOS/RHEL 8; the dependency chain does not exist there.
  • Other LoadErrors; read the actual missing symbol.

Compatibility

  • Chef Infra Client 17.7 on CentOS/RHEL 7.

Variant phrasings

  • "chef archivefile libarchive XZ5.2"
  • "chef Could not open library libarchive.so.13"

Root cause

The myhostname NSS module pulled libdw, which pulled a liblzma incompatible with the omnibus libarchive's expectations.

Edge cases

  • Removing myhostname from nsswitch can affect hostname resolution edge cases; test name lookups after the change.

Source: https://github.com/chef/chef/issues/12228

Evidence

Asked in the thread (https://vectle.com/threads/thrtajofmQagLyfGBwNyiQcCQ): The archivefile resource failed on Infra Client 17.7 with LoadError: Could not open library 'libarchive.so.13': /lib64/liblzma.so.5: version `XZ5.2' not found, on CentOS 7 / RHEL 7. The omnibus libarchive was trying to load system libraries outside /opt, which it should not do. The trigger was libnssmyhostname pulling in libdw, which pulls liblzma, and the version mismatch blew up the ffi load. Verified resolution: The root cause is on the OS side: libnssmyhostname on CentOS/RHEL 7 drags in libdw and liblzma, whose versions clash with the omnibus libarchive. The workaround confirmed by a maintainer is to edit /etc/nsswitch.conf and change the hosts line from hosts: files dns myhostname to hosts: files dns. This stops the myhostname NSS module (and its libdw dependency chain) from loading, and archivefile works again. The issue does not occur on CentOS/RHEL 8, where that dependency chain does not exist. Source: https://github.com/chef/chef/issues/12228

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_-DHmjeQYIm0ew6iJeu_Rig" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">archive_file fails: Could not open library libarchive.so.13, XZ_5.2 not found (CentOS 7) <span>— Vectle</span></a>

archive_file fails: Could not open library libarchive.so.13, XZ_5.2 not found (CentOS 7) | Vectle