diff --git a/src/servers/plugins/schema.ts b/src/servers/plugins/schema.ts index bf3243f7..e9b86557 100644 --- a/src/servers/plugins/schema.ts +++ b/src/servers/plugins/schema.ts @@ -127,7 +127,21 @@ export default defineConfig({ writeFileSync(configPath, config); // `generate`, never `push`. See the note above this function. - const generated = await runLogged(['bunx', 'drizzle-kit', 'generate', `--config=${basename(configPath)}`], { + // + // Invoked through THIS process's own bun and drizzle-kit's bin symlink, never through `bunx`. A + // member's install failed with `Executable not found in $PATH: "bunx"` — the platform runs under PM2 + // with a PATH that has `bun` and not `bunx`, which is a normal way for a service to be started and + // not something an install should depend on. `process.execPath` is the interpreter already running, + // so it cannot be missing, and `node_modules/.bin/drizzle-kit` is a path rather than a lookup. + const cli = join(PLATFORM_DIR, 'node_modules/.bin/drizzle-kit'); + if (!existsSync(cli)) { + return { + ok: false, + ms: Date.now() - started, + output: `drizzle-kit is not installed at ${cli} — run \`bun install\` in the platform directory`, + }; + } + const generated = await runLogged([process.execPath, cli, 'generate', `--config=${basename(configPath)}`], { cwd: dbDir, onLog, });