Skip to content

Commit 82cabfc

Browse files
author
Marcus Pousette
committed
scripts(fetch-prebuilt): log platform/arch and allow overrides (SQLITE3_VEC_TRIPLE/PLATFORM/ARCH/EXT) to diagnose/force correct asset on macOS
1 parent 22ef076 commit 82cabfc

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

scripts/fetch-prebuilt.cjs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
const https = require('https');
1111
const fs = require('fs');
1212
const path = require('path');
13+
const os = require('os');
1314

1415
const root = process.cwd();
1516
const pkg = require(path.join(root, 'package.json'));
@@ -29,14 +30,22 @@ function detectLibc() {
2930
}
3031

3132
function platformTriple() {
32-
const { platform, arch } = process;
33+
// Allow explicit overrides for debugging or special environments
34+
const forceTriple = process.env.SQLITE3_VEC_TRIPLE;
35+
if (forceTriple) return forceTriple;
36+
const forcePlatform = process.env.SQLITE3_VEC_PLATFORM;
37+
const forceArch = process.env.SQLITE3_VEC_ARCH;
38+
const platform = (forcePlatform || process.platform);
39+
const arch = (forceArch || process.arch);
3340
if (platform === 'darwin') return `darwin-${arch}`;
3441
if (platform === 'win32') return `win32-${arch}`;
3542
if (platform === 'linux') return `linux-${arch}-${detectLibc()}`;
3643
return `${platform}-${arch}`;
3744
}
3845

3946
function fileExt() {
47+
const forceExt = process.env.SQLITE3_VEC_EXT;
48+
if (forceExt) return forceExt;
4049
if (process.platform === 'darwin') return 'dylib';
4150
if (process.platform === 'win32') return 'dll';
4251
return 'so';
@@ -75,6 +84,20 @@ async function download(url, dest) {
7584
async function main() {
7685
const triple = platformTriple();
7786
const ext = fileExt();
87+
// Helpful diagnostics
88+
const diag = {
89+
platform: process.platform,
90+
arch: process.arch,
91+
osRelease: os.release?.() || undefined,
92+
force: {
93+
triple: process.env.SQLITE3_VEC_TRIPLE || undefined,
94+
platform: process.env.SQLITE3_VEC_PLATFORM || undefined,
95+
arch: process.env.SQLITE3_VEC_ARCH || undefined,
96+
ext: process.env.SQLITE3_VEC_EXT || undefined,
97+
},
98+
resolved: { triple, ext },
99+
};
100+
console.log('[sqlite3-vec] Platform detection:', JSON.stringify(diag));
78101
const verWithV = pkg.version.startsWith('v') ? pkg.version : `v${pkg.version}`;
79102
const verNoV = verWithV.replace(/^v/, '');
80103
const resolved = repoFromPackage();

0 commit comments

Comments
 (0)