ui: don't trust a partial dist dir (fixes 'missing loading.html' build abort on Termux/sharp failure)#225
Merged
Conversation
…bedding
A UI dist directory was trusted on the presence of index.html alone. When an
npm PWA-assets build dies partway -- e.g. the native `sharp` step failing on
Termux / very new Node.js, which is common -- it can leave a dist with
index.html but without loading.html, the PWA manifest, service worker, etc.
ui-assets.cmake would then hand that partial dir to llama-ui-embed, which
aborts the entire build with 'missing required asset(s): loading.html ...'.
Add dist_is_complete(): a dist is only usable if it holds the complete asset
set llama-ui-embed requires (index.html, loading.html, manifest.webmanifest,
sw.js, build.json, version.json, bundle*.{js,css}, workbox*.js), matched by
basename recursively to mirror embed.cpp's own check. Gate all three trust
points on it:
- pre-built tools/ui/dist: skip a partial dir, fall through to npm/HF
- HF stamp-skip: only skip the fetch when the cached dist is complete
- final fallback: if provisioning failed and the dist is partial, drop it
and build a no-embedded-UI binary with a clear message instead of aborting
Net effect: a broken/partial UI build (sharp failure, interrupted download)
falls through to the HF-downloaded prebuilt UI, or degrades to a no-UI binary,
instead of hard-failing the whole llama.cpp build. Reported by two users hitting
the 'missing loading.html' abort on Termux.
dist_is_complete verified via cmake -P against partial/complete/empty/nested
fixtures (nested = real vite assets/ subdir layout).
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.
Problem
scripts/ui-assets.cmaketrusted a UI dist directory on the presence ofindex.htmlalone. When an npm PWA-assets build dies partway through, it can leave a dist withindex.htmlbut missingloading.html, the PWA manifest, the service worker, etc. The script then hands that partial dir tollama-ui-embed, which aborts the entire build:This has now hit two users. The common trigger is the native
sharpdependency (via@vite-pwa/assets-generator) failing on Termux / very new Node.js:npm exits non-zero, but a partial
tools/ui/dist/(or a stale one) is left behind and gets picked up as if it were a valid pre-built UI.Fix
Add
dist_is_complete(): a dist is only usable if it holds the complete asset setllama-ui-embedrequires (index.html,loading.html,manifest.webmanifest,sw.js,build.json,version.json,bundle*.{js,css},workbox*.js), matched by basename recursively to mirrorembed.cpp's own check. Gate all three trust points on it:tools/ui/dist: skip a partial dir, fall through to npm/HFNet effect: a broken/partial UI build (sharp failure, interrupted download) now falls through to the HF-downloaded prebuilt UI, or degrades to a no-UI binary — it no longer hard-fails the whole llama.cpp build.
Testing
dist_is_completeverified viacmake -Pagainst four fixtures:assets/subdir layout)For affected users right now
Cleanest workaround without this patch: configure with
-DBUILD_UI=OFFso the npm/sharp path never runs and the HF-downloaded prebuilt UI is used.rm -rf buildalso recovers, since a clean build has no partial dist to trip over and the HF fallback provisions a complete one.