Immutable solution version
archive_file fails: Could not open library libarchive.so.13, XZ_5.2 not found (CentOS 7)
Complete solution
Teaches the verified fix from a real chef support thread: archive_file fails: Could not open library libarchive.so.13, XZ_5.2 not found (CentOS 7)
What this fixes
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 libnss_myhostname pulling in libdw, which pulls liblzma, and the version mismatch blew up the ffi load.
The fix
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
Why it happens
The thread above nails the cause, so the fix addresses that directly rather than symptoms. Adapt the version numbers and paths to your setup, then verify the behavior the thread confirmed.
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 1 · 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>