nikivdev/code · error · anyhow::Error

Postgres project path not found: {} (override with --project

Error message

Postgres project path not found: {} (override with --project)

What it means

resolve_postgres_project validates that the Postgres (Drizzle/Bun) project directory exists before running generation or migrations. If the resolved project path (from --project, config, or a default like `postgres` under the app dir) does not exist on disk, it bails with this message. The message also hints that --project can override the path.

Source

Thrown at src/storage.rs:96

        println!("Generating migrations in {}", project_dir.display());
        run_bun_script(&project_dir, "db:generate", Some(&database_url))?;
    }

    println!("Applying migrations in {}", project_dir.display());
    run_bun_script(&project_dir, "db:migrate", Some(&database_url))
}

fn resolve_postgres_project(project: Option<PathBuf>) -> Result<PathBuf> {
    let path = match project {
        Some(path) => path,
        None => PathBuf::from(tilde(DEFAULT_POSTGRES_PROJECT).as_ref()),
    };

    if path.exists() {
        return Ok(path);
    }

    bail!(
        "Postgres project path not found: {} (override with --project)",
        path.display()
    )
}

fn resolve_database_url(database_url: Option<&str>, project_dir: &Path) -> Result<String> {
    if let Some(url) = database_url {
        let trimmed = url.trim();
        if !trimmed.is_empty() {
            return Ok(trimmed.to_string());
        }
    }

    for key in [
        "DATABASE_URL",
        "PLANETSCALE_DATABASE_URL",
        "PSCALE_DATABASE_URL",
    ] {

View on GitHub (pinned to a747e741ae)

Solutions

  1. Re-run the command with an explicit --project <path> pointing at the existing Postgres project directory.
  2. Verify the project directory exists (ls the resolved path) and that you're running the CLI from the expected working directory.
  3. Create or restore the missing directory (e.g. scaffold the Drizzle project or check out the deleted files).
  4. Fix the configured/default project path in your config if it points to an old location.

Example fix

// before
myapp db migrate
// error: Postgres project path not found: ./services/postgres
// after
myapp db migrate --project ./packages/db-postgres
Defensive patterns

Strategy: validation

Validate before calling

const projectPath = getResolvedPostgresProjectPath();
if (!fs.existsSync(projectPath)) {
  throw new Error(`Postgres project dir missing: ${projectPath}. Pass --project <path>.`);
}
await cli.postgresMigrate({ project: projectPath });

Type guard

function isExistingDir(p: string): p is string {
  return fs.existsSync(p) && fs.statSync(p).isDirectory();
}

Try / catch

try {
  await postgresMigrate({ project });
} catch (e) {
  if (String(e).includes('Postgres project path not found')) {
    console.error(`Project dir not found at configured path; pass --project explicitly.`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling postgres_generate or postgres_migrate when the resolved project directory's path.exists() returns false — i.e. the default directory was never created, the configured path is wrong/typo'd/renamed, or the command is run from the wrong working directory.

Common situations: Fresh clone where the postgres subproject hasn't been initialized; user renamed or moved the project folder; running the CLI outside the repo root so relative path resolution misses; typo in the configured project path; monorepo where the schema lives in a package the default path doesn't point at.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/78cef344d459fdfd. Report an issue: GitHub.