question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma Studio cannot be started with the packaged CLI (because Client can not be generated)

See original GitHub issue

Bug description

Running prisma studio launches the studio in the browser and then crashes:

Environment variables loaded from .env
Prisma schema loaded from tests/data/schema.prisma
Prisma Studio is up on http://localhost:5555
Unable to get DMMF from Prisma Client:  AggregateError: 
    Error: Generator at /snapshot/node_modules/prisma/prisma-client/generator-build/index.js could not start:
    internal/modules/cjs/loader.js:967
      throw err;
      ^
    Error: Cannot find module '/prisma-client-py/--max-old-space-size=8096'
        at Function._resolveFilename (pkg/prelude/bootstrap.js:1459:46)
        at Function.runMain (pkg/prelude/bootstrap.js:1488:12)
        at internal/main/run_main_module.js:17:47 {
      code: 'MODULE_NOT_FOUND',
      requireStack: []
    }
        at Timeout._onTimeout (/snapshot/node_modules/prisma/build/index.js:37450:25)
    at next (/snapshot/node_modules/prisma/build/index.js:17854:25)
    at /snapshot/node_modules/prisma/build/index.js:17875:17

Should be noted that the standalone Prisma Studio app and running with npx prisma studio can both be successfully launched.

How to reproduce

#!/bin/bash

set -eux

git clone https://github.com/RobertCraigie/prisma-client-py
cd prisma-client-py

python3 -m venv .venv

set +x
source .venv/bin/activate
set -x

pip install -U -e .

python -m prisma studio --schema=tests/data/schema.prisma

This will either hang or crash.

Expected behavior

The studio should be launched successfully.

Prisma information

datasource db {
  provider = "sqlite"
  url      = "file:dev.db"
}

generator db {
  provider               = "prisma-client-py"
  interface              = "asyncio"
  recursive_type_depth   = 5
  partial_type_generator = "tests/scripts/partial_type_generator.py"
}

model Post {
  id         String     @id @default(cuid())
  created_at DateTime   @default(now())
  updated_at DateTime   @updatedAt
  title      String
  published  Boolean
  views      Int        @default(0)
  desc       String?
  author     User?      @relation(fields: [author_id], references: [id])
  author_id  String?
  categories Category[] @relation(references: [id])
}

model User {
  id      String   @id @default(cuid())
  name    String
  email   String?  @unique
  posts   Post[]
  profile Profile?
}

model Category {
  id    Int    @id @default(autoincrement())
  posts Post[] @relation(references: [id])
  name  String
}

model Profile {
  id      Int    @id @default(autoincrement())
  user    User   @relation(fields: [user_id], references: [id])
  user_id String @unique
  bio     String
}

// model that just exists for testing different schema types
model Types {
  id       Int      @id @default(autoincrement())
  bool_    Boolean  @default(false)
  string   String   @default("")
  bytes    Bytes    @default("")
  bigint   BigInt   @default(0)
  integer  Int      @default(0)
  float_   Float    @default(0)
  datetime DateTime @default(now())
}

Environment & setup

  • OS: Mac OS
  • Database: SQLite
  • Node.js version: N/A

Prisma Version

prisma                : 3.7.0
@prisma/client        : Not found
Current platform      : darwin
Query Engine (Binary) : query-engine 8746e055198f517658c08a0c426c7eec87f5a85f (at ../../../../../../../var/folders/ql/0v8h20s972s6zz4t_3qc49bc0000gp/T/prisma/binaries/engines/8746e055198f517658c08a0c426c7eec87f5a85f/prisma-query-engine-darwin, resolved by PRISMA_QUERY_ENGINE_BINARY)
Migration Engine      : migration-engine-cli 8746e055198f517658c08a0c426c7eec87f5a85f (at ../../../../../../../var/folders/ql/0v8h20s972s6zz4t_3qc49bc0000gp/T/prisma/binaries/engines/8746e055198f517658c08a0c426c7eec87f5a85f/prisma-migration-engine-darwin, resolved by PRISMA_MIGRATION_ENGINE_BINARY)
Introspection Engine  : introspection-core 8746e055198f517658c08a0c426c7eec87f5a85f (at ../../../../../../../var/folders/ql/0v8h20s972s6zz4t_3qc49bc0000gp/T/prisma/binaries/engines/8746e055198f517658c08a0c426c7eec87f5a85f/prisma-introspection-engine-darwin, resolved by PRISMA_INTROSPECTION_ENGINE_BINARY)
Format Binary         : prisma-fmt 8746e055198f517658c08a0c426c7eec87f5a85f (at ../../../../../../../var/folders/ql/0v8h20s972s6zz4t_3qc49bc0000gp/T/prisma/binaries/engines/8746e055198f517658c08a0c426c7eec87f5a85f/prisma-prisma-fmt-darwin, resolved by PRISMA_FMT_BINARY)
Default Engines Hash  : 8746e055198f517658c08a0c426c7eec87f5a85f
Studio                : 0.445.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
max-programmingcommented, Jul 31, 2022

Thanks a lot @RobertCraigie 😄 !

Just FYI I was stuck while generating the client too and I realized I had to change prisma-client.js to prisma-client.py manually in the schema file.

1reaction
janpiocommented, Jan 2, 2022

Sounds related to https://github.com/prisma/prisma/issues/10564 - under the hood Studio also uses a generated Prisma Client, so if generating is not possible, using Prisma Studio is also not possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating the client (Concepts) - Prisma
This page explains how to generate Prisma Client. It also provides additional context on the generated client, typical workflows and Node.js configuration.
Read more >
Prisma CLI Installation (Reference)
The Prisma CLI is typically installed as a development dependency, that's why the --save-dev (npm) and --dev (Yarn) options are used in the...
Read more >
Prisma CLI Command Reference
The generate command is most often used to generate Prisma Client with the prisma-client-js generator. This does three things: Searches the current directory ......
Read more >
Prisma Client API (Reference)
You must re-generate the Prisma Client each time you add or rename a data source. Datasource names are included in the generated client....
Read more >
Relational databases - Add to existing project - Prisma
Learn how to add Prisma to an existing Node.js or TypeScript project by connecting it to your relational database and generating a Prisma...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found