nikivdev/code · error · anyhow::Error
bun run {} failed with status {}
Error message
bun run {} failed with status {} What it means
run_bun_script shells out to `bun run <script>` inside the Postgres project directory (via Command::new("bun")). If the child process exits with a non-zero status, the wrapper surfaces the script name and exit status as this error. It means the underlying bun script (e.g. drizzle-kit generate/migrate) itself failed.
Source
Thrown at src/storage.rs:189
fn run_bun_script(project_dir: &Path, script: &str, database_url: Option<&str>) -> Result<()> {
let mut cmd = Command::new("bun");
cmd.args(["run", script]);
cmd.current_dir(project_dir);
if let Some(url) = database_url {
cmd.env("DATABASE_URL", url);
}
cmd.stdout(Stdio::inherit());
cmd.stderr(Stdio::inherit());
let status = cmd.status().with_context(|| {
format!(
"failed to run bun script '{}' in {}",
script,
project_dir.display()
)
})?;
if !status.success() {
bail!("bun run {} failed with status {}", script, status);
}
Ok(())
}
fn jazz_new(
kind: JazzStorageKind,
name: Option<String>,
peer: Option<String>,
api_key: Option<String>,
environment: &str,
) -> Result<()> {
let project = get_project_name()?;
let default_name = match kind {
JazzStorageKind::Mirror => format!("{}-jazz-mirror", sanitize_name(&project)),
JazzStorageKind::EnvStore => format!("{}-jazz-env", sanitize_name(&project)),
JazzStorageKind::AppStore => format!("{}-jazz-app", sanitize_name(&project)),
};
let name = name.unwrap_or(default_name);View on GitHub (pinned to a747e741ae)
Solutions
- Re-run `bun run <script>` manually inside the project directory to see the full underlying error output.
- Ensure dependencies are installed: `bun install` in the project directory (drizzle-kit present).
- Verify the script name exists in the project's package.json scripts.
- Fix the schema/migration or database connectivity problem that made the script exit non-zero.
Example fix
// before cd services/postgres && myapp db generate // bun run db:generate failed with status 1 // after — debug directly cd services/postgres && bun run db:generate # shows real drizzle-kit error, fix it, then retry the CLI
Defensive patterns
Strategy: try-catch
Validate before calling
const pkg = JSON.parse(fs.readFileSync(path.join(projectDir, 'package.json'), 'utf8'));
if (!pkg.scripts?.[scriptName]) {
throw new Error(`Script "${scriptName}" not defined in ${projectDir}/package.json`);
}
if (!fs.existsSync(path.join(projectDir, 'node_modules'))) {
throw new Error('Dependencies not installed; run `bun install` first.');
} Try / catch
try {
await postgresGenerate({ project });
} catch (e) {
const m = String(e).match(/bun run (.+) failed with status (\d+)/);
if (m) {
console.error(`bun script "${m[1]}" exited ${m[2]}. Re-run it directly for full output:`);
console.error(` cd ${project} && bun run ${m[1]}`);
return;
}
throw e;
} Prevention
- Run the underlying bun scripts locally before wiring them into CLI commands.
- Keep drizzle-kit and other dev deps installed and pinned in the project.
- Ensure package.json in the project directory defines the exact script names invoked.
- Validate Drizzle schema files (compile/typecheck) before running generate/migrate in CI.
When it happens
Trigger: postgres_generate or postgres_migrate invoking run_bun_script where the spawned `bun run <script>` completes with status.success() == false — e.g. non-zero exit from drizzle-kit, missing script in package.json, or bun's own failure to start the script.
Common situations: Drizzle schema has a syntax error or invalid migration; drizzle-kit not installed (bun can't resolve the binary); package.json doesn't define the script being invoked; database unreachable causing migrate to fail; bun not on PATH (though that usually fails earlier at spawn).
Related errors
- {} exited with {}
- Tool '{}' exited with status: {}
- Lin.app is not running
- Agent exited with status: {}
- gen exited with status: {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/6ff52dd539bea1f6.
Report an issue: GitHub.