Skip to content

Commit 4b27114

Browse files
author
flowcore-platform
committed
feat(duckdb): ✨ Add support for native arm64 DuckDB on macOS
1 parent 5957ac6 commit 4b27114

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"
44
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
5+
import { spawnSync } from "node:child_process"
56
import { parseArgs } from "node:util"
7+
import os from "node:os"
68
import { z } from "zod"
79
import pkg from "../package.json"
810
import {
@@ -18,6 +20,22 @@ import {
1820
} from "./tools/duckdb-tools"
1921
import { exchangePat } from "./utils/pat-exchange"
2022

23+
const arch = os.arch()
24+
const platform = os.platform()
25+
26+
if (platform === "darwin" && arch === "arm64") {
27+
// Try native arm64 first
28+
try {
29+
require("duckdb")
30+
} catch (error) {
31+
// If native arm64 fails, use Rosetta
32+
const result = spawnSync("arch", ["-x86_64", process.execPath, ...process.argv.slice(1)], {
33+
stdio: "inherit",
34+
})
35+
process.exit(result.status)
36+
}
37+
}
38+
2139
// Parse command line arguments
2240
const { values: parsedValues } = parseArgs({
2341
// Use process.argv if Bun is not available

0 commit comments

Comments
 (0)