Skip to content

Non-empty target directory is the top create failure, and the message sends existing projects to --force #123

Closed

Description

@ankur-arch

Summary

A non-empty target directory is the most common reason a create-prisma run ends without a project. In the last 28 days of CLI telemetry, failure-reason: target_directory_not_empty accounts for about 28% of all failed runs, ahead of dependency install failures and unsupported Node versions.

The only guidance the CLI gives is to overwrite:

$ cd existing-app && npm create prisma@latest .

┌  ◭ Create Prisma 8
└  Target directory . is not empty. Use --force to continue.

([email protected], Node 24, macOS. Same message in --json mode under error.message.)

Why it matters

Three different people hit this message, and it only fits one of them.

  • Someone adding Prisma to an app they already have. They run create-prisma in the app folder or with .. For them --force is the wrong advice: it scaffolds a starter over their files and replaces any Prisma config, contract and database-client files. The right path is prisma orm init, which the CLI never mentions.
  • Someone retrying after a failed run. Install or deploy failed, the directory was left behind, and they rerun the same command. --force is the right answer here, and it is the case the message was written for.
  • Someone who picked a name that is already taken. They want a fresh project and only need a different name.

Interactive runs get the worst version of it. The directory is only checked after the template prompt, so people answer two questions and are then dropped back to the shell instead of being asked for another name.

We cannot tell the three groups apart today. The failure is raised before the create context exists, so target-directory-state is null on every one of these events. That makes it hard to decide how much to invest in a real "add to existing project" path.

Proposal

  1. Say what to do for each case. Look at what is in the directory (a package.json, a prisma.config.ts, or neither) and lead with the matching next step: prisma orm init for an existing app, the Prisma CLI or --force for an existing Prisma project, a different name otherwise.
  2. Ask again in interactive runs. Check the directory right after the name prompt, before the template prompt, and re-prompt for the name instead of exiting.
  3. Record what kind of directory it was. Add a coarse target-directory-kind value to the failure event (no names, no paths) so the split between the three groups is visible.

Follow-ups

  • Decide, from the data in (3), whether create-prisma should offer to run prisma orm init in place for existing apps instead of only pointing at it.
  • https://www.prisma.io/docs/prisma-orm/add-to-existing-project returns 404 (only the per-database pages exist), so there is no single page to link for this path.

Activity

  1. added
    enhancement
    on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions