Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix(windows): stop the arm64 build picking x64 support binaries

Minh141120fe1b0e026fb5
diff --git a/.github/workflows/template-tauri-build-windows-arm64.yml b/.github/workflows/template-tauri-build-windows-arm64.yml
index a5b686caa..72f9f2eb9 100644
--- a/.github/workflows/template-tauri-build-windows-arm64.yml
+++ b/.github/workflows/template-tauri-build-windows-arm64.yml
@@ -310,6 +310,16 @@ jobs:
}
echo "signtool -> $TAURI_WINDOWS_SIGNTOOL_PATH"
+ # scripts/download-bin.mjs names the bun/uv sidecars from node's
+ # os.arch(), while the NSIS retarget below rewrites them to aarch64
+ # unconditionally. An emulated x64 node would name them x86_64-* and
+ # the mismatch would not surface until bundling, after the engine.
+ node_arch=$(node -p 'process.arch')
+ echo "node -> $node_arch"
+ [ "$node_arch" = "arm64" ] || {
+ echo "::error::node reports $node_arch, not arm64 -- the bun/uv sidecars would be named for the wrong target"; exit 1;
+ }
+
- name: Update app version and product name
shell: bash
run: |
diff --git a/scripts/download-bin.mjs b/scripts/download-bin.mjs
index cb1a055c2..244379ca5 100644
--- a/scripts/download-bin.mjs
+++ b/scripts/download-bin.mjs
@@ -96,22 +96,34 @@ function matchSqliteVecAsset(assets, platform, arch) {
: ['linux']
const archHints = arch === 'arm64' ? ['arm64', 'aarch64'] : ['x86_64', 'x64', 'amd64']
+ // The two fallbacks below drop the arch hint, so without this an arch with no
+ // asset takes another one's: windows-arm64 has no sqlite-vec build, and would
+ // otherwise land the windows-x86_64 dll, which then fails to load at runtime
+ // and silently costs ANN acceleration. Skipping the extension entirely is the
+ // supported outcome -- the caller falls back to linear search.
+ const foreignArchHints =
+ arch === 'arm64'
+ ? ['x86_64', 'x64', 'amd64', 'i686']
+ : ['arm64', 'aarch64', 'armv7']
const extHints = ['zip', 'tar.gz']
const lc = (s) => s.toLowerCase()
const candidates = assets
.filter((a) => a && a.browser_download_url && a.name)
.map((a) => ({ name: lc(a.name), url: a.browser_download_url }))
+ .filter((c) => !foreignArchHints.some((h) => c.name.includes(h)))
// Prefer exact OS + arch matches
let matches = candidates.filter((c) => osHints.some((o) => c.name.includes(o)) && archHints.some((h) => c.name.includes(h)) && extHints.some((e) => c.name.endsWith(e)))
if (matches.length) return matches[0].url
- // Fallback: OS only
+ // Fallback: OS only. Safe because foreign architectures are already filtered
+ // out above, so this can only relax the arch *spelling*, not the arch.
matches = candidates.filter((c) => osHints.some((o) => c.name.includes(o)) && extHints.some((e) => c.name.endsWith(e)))
if (matches.length) return matches[0].url
- // Last resort: any asset with shared library extension inside is unknown here, so pick any zip/tar.gz
- matches = candidates.filter((c) => extHints.some((e) => c.name.endsWith(e)))
- return matches.length ? matches[0].url : null
+ // No OS-only-last-resort: it could fire solely when nothing matches this OS,
+ // which means there is no build for the platform, and any archive it picked
+ // would be for a different one. Returning null skips the optional extension.
+ return null
}
async function fetchLatestSqliteVecUrl(platform, arch) {