fix: ensure cross-target LanceDB binaries are correctly copied (#9100)

* fix: install lancedb binary for cross-target builds

* chore: add temporary darwin build workflow

* chore: remove temporary darwin workflow

* fix: prettier formatting in prepackage.js

Co-authored-by: nate <nate@continue.dev>

* fix: ensure cross-target LanceDB binaries copied

* fix: retain target lancedb binary in vsix

* Update prepackage.js

* fix: install LanceDB packages sequentially in binary build

The previous code ran installAndCopyNodeModules in parallel for all
targets, but they all write to node_modules/@lancedb. This caused
race conditions where files could be partially written or empty.

Changed to sequential installation to prevent file corruption.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: add diagnostic logging for lancedb copy

* chore: add detailed diagnostics to install-copy-nodemodule

* fix: remove cached lancedb before fresh copy

ncp's clobber option doesn't reliably overwrite cached files.
Delete destination directory before copying to ensure fresh install.

* chore: clean up diagnostic code, keep fix for cached lancedb

Root cause: ncp doesn't reliably overwrite cached files.
Fix: Remove destination directory before copying fresh lancedb binaries.

---------

Co-authored-by: continue[bot] <continue[bot]@users.noreply.github.com>
Co-authored-by: nate <nate@continue.dev>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Patrick Erichsen
2025-12-10 10:39:42 -08:00
committed by GitHub
parent eb1e581cb9
commit 291f8f5dd2
2 changed files with 24 additions and 10 deletions

View File

@@ -101,21 +101,22 @@ async function buildWithEsbuild() {
),
);
const copyLanceDBPromises = [];
// Install LanceDB packages sequentially to avoid race conditions
// when multiple packages copy to the same node_modules/@lancedb directory
for (const target of targets) {
if (!TARGET_TO_LANCEDB[target]) {
continue;
}
console.log(`[info] Downloading for ${target}...`);
copyLanceDBPromises.push(
installAndCopyNodeModules(TARGET_TO_LANCEDB[target], "@lancedb"),
);
console.log(`[info] Downloading LanceDB for ${target}...`);
try {
await installAndCopyNodeModules(TARGET_TO_LANCEDB[target], "@lancedb");
console.log(`[info] Copied LanceDB for ${target}`);
} catch (err) {
console.error(`[error] Failed to copy LanceDB for ${target}:`, err);
process.exit(1);
}
}
await Promise.all(copyLanceDBPromises).catch(() => {
console.error("[error] Failed to copy LanceDB");
process.exit(1);
});
console.log("[info] Copied all LanceDB");
console.log("[info] All LanceDB packages installed");
// tree-sitter-wasm
const treeSitterWasmsDir = path.join(out, "tree-sitter-wasms");

View File

@@ -44,6 +44,19 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
// Without this it seems the file isn't completely written to disk
await new Promise((resolve) => setTimeout(resolve, 2000));
// Remove existing destination directory to ensure fresh copy
// ncp's clobber option doesn't reliably overwrite cached files
const packageSubdir = packageName.replace("@lancedb/", "");
const destDir = path.join(
currentDir,
"node_modules",
toCopy,
packageSubdir,
);
if (fs.existsSync(destDir)) {
rimrafSync(destDir);
}
// Copy the installed package back to the current directory
await new Promise((resolve, reject) => {
ncp(