Fix Linux multiarch dependency detection and OVMS libxml2 crash - #558
Open
beranradek wants to merge 2 commits into
Open
Fix Linux multiarch dependency detection and OVMS libxml2 crash#558beranradek wants to merge 2 commits into
beranradek wants to merge 2 commits into
Conversation
isAptPackageInstalled() queried dpkg-query without an architecture qualifier and compared the output to the exact string "installed". On any system with a foreign architecture enabled (e.g. i386 packages pulled in by Wine or Steam), dpkg-query matches one record per installed architecture and concatenates the status field with no separator, e.g. "installedinstalled" for a package installed for both amd64 and i386. That fails the exact-match check even though the package genuinely is installed, so OpenVINO/ComfyUI Linux setup wrongly reports required packages (libgomp1, libnuma1, ocl-icd-libopencl1, ...) as still missing after the installer runs, and setup fails with "Dependencies still missing after installer". Accept any repetition of "installed" while still rejecting unrelated statuses that contain it as a substring (e.g. "not-installed").
ensureOvmsMissingLibSymlinks() resolves a missing OVMS shared library (e.g. libxml2.so.2) to a compatible system library by building a soname -> path map from `ldconfig -p` output. On a system with a foreign architecture enabled (e.g. i386 pulled in by Wine/Steam), ldconfig -p lists one entry per installed architecture under the same soname with no architecture-aware precedence, so the map ends up keyed to whichever line happens to come last: libxml2.so.16 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libxml2.so.16 libxml2.so.16 (libc6) => /usr/lib/i386-linux-gnu/libxml2.so.16 When the i386 line wins, the compat symlink points OVMS (a 64-bit process) at a 32-bit library, and OVMS crashes on startup with "error while loading shared libraries: libxml2.so.2: wrong ELF class: ELFCLASS32", which surfaces in the UI as "Failed to start transcription server" (and would affect any other OVMS feature needing a fallback library). Extract the parsing into parseLdconfigOutput() and make it architecture-aware: an x86-64-tagged entry always wins over a foreign-arch one for the same soname, regardless of line order. AI Playground's Linux build targets x86-64 only, so this is safe and matches the existing hardcoded x86_64-linux-gnu paths used elsewhere in this file's Linux support code. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related bugs affecting Linux systems with a foreign architecture enabled (e.g. i386 packages pulled in by Wine or Steam), both caused by code that reads multiarch
dpkg/ldconfigoutput without being architecture-aware.1.
isAptPackageInstalled()wrongly reports installed packages as missingWebUI/electron/subprocesses/linuxPackageInstaller.tsrunsdpkg-query -W -f='${db:Status-Status}' <pkg>without an architecture qualifier and compares the output to the exact stringinstalled. On a multiarch system,dpkg-querymatches one record per installed architecture and concatenates the status field with no separator, e.g.installedinstalledfor a package installed for bothamd64andi386. That breaks the exact-match check even though the package genuinely is installed, so OpenVINO (and ComfyUI) Linux setup wrongly reports required packages as still missing after the installer step runs, and setup fails withDependencies still missing after installer: libgomp1, libnuma1, ocl-icd-libopencl1.Reproduced on a stock Ubuntu install with
libwine:i386/libx265-215:i386/libsoxr0:i386present, which pull ini386copies oflibgomp1,libnuma1, andocl-icd-libopencl1alongside theamd64ones already required by OpenVINO.Fix: accept any repetition of
installed(covers 1+ architectures reporting the same status) while still rejecting unrelated statuses that contain the substring, likenot-installed:2. OVMS crashes with
wrong ELF class: ELFCLASS32loadinglibxml2ensureOvmsMissingLibSymlinks()resolves a missing OVMS shared library (e.g.libxml2.so.2) to a compatible system library via asoname -> pathmap built fromldconfig -p. On the same kind of multiarch system,ldconfig -plists one entry per architecture under the identical soname key with no architecture-aware precedence:The map ends up keyed to whichever line happens to come last. When that's the i386 line, the compat symlink points OVMS (a 64-bit process) at a 32-bit library, and OVMS crashes on startup with
error while loading shared libraries: libxml2.so.2: wrong ELF class: ELFCLASS32. This surfaces in the UI as "Failed to start transcription server" when enabling Speech to Text, and would affect any other OVMS feature needing the same kind of fallback library.Fix: extract the
ldconfig -pparsing intoparseLdconfigOutput()and make it architecture-aware: anx86-64-tagged entry always wins over a foreign-arch entry for the same soname, regardless of line order. AI Playground's Linux build targets x86-64 only, so this is safe and matches the existing hardcodedx86_64-linux-gnupaths used elsewhere in this file's Linux support code.Test plan
linuxPackageInstaller.test.tscovering single-arch and multiarchdpkg-queryoutput.openVINOBackendService.test.tscoveringparseLdconfigOutput()with real multiarchldconfig -poutput reproduced from an affected system (x86-64 entry first, foreign-arch entry first, foreign-arch-only fallback, unparsable lines).libxml2.so.2ELFCLASS32crash on a live installation (Ubuntu with i386 foreign architecture enabled) and confirmed the fix resolves it:lddon the OVMS binary now resolveslibxml2.so.2to the x86-64 library instead of the i386 one.npx vitest run electron/test/subprocesses/),tsc --noEmit, andeslintpass with no regressions.🤖 Generated with Claude Code