medz / prisma-dart

Prisma Client Dart is an auto-generated type-safe ORM. It uses Prisma Engine as the data access layer and is as consistent as possible with the Prisma Client JS/TS APIs.
https://prisma.pub
BSD 3-Clause "New" or "Revised" License
459 stars 31 forks source link

flutter platform ERROR"spawn dart run orm ENOENT" #416

Closed lsxqer closed 2 months ago

lsxqer commented 2 months ago

these are my local files

schema.prisma

generator client {
  provider = "dart run orm"
}

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

model User {
  id    Int     @id @default(autoincrement())
  age   Int
  email String  @unique
  name  String?
}

.env

DATABASE_URL="fil:./test.db"
dependencies:
  flutter:
  orm: ^3.4.8

I followed the instructions in the document:

1. dart pub add orm
2. bun prisma init --generator-provider="dart run orm"
3.  bux prisma generate -> error
I encountered an error while executing this command
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Error: spawn dart run orm ENOENT

I want to know why this is? Did I use it incorrectly? How should I modify it

medz commented 2 months ago

@lsxqer Is it Windows? You can try editing schema.prisma and replacing dart with the full path to the specific dart binary file.

The dart command should be a global command, but it doesn't seem to be handled correctly.

medz commented 2 months ago

https://thecodersblog.com/demystifying-error-spawn-enoent-node-js

lsxqer commented 2 months ago

The command 'dart' is already in the path and is a global command

I used it according to the documentation, but it seems that it is not working properly and cannot generate the code files required by PrismAClient

dart -v A command-line utility for Dart development.

Usage: dart <command|dart-file> [arguments]

Global options: -v, --verbose Show additional command output. --version Print the Dart SDK version. --enable-analytics Enable analytics. --disable-analytics Disable analytics. --suppress-analytics Disallow analytics for this dart * run without changing the analytics configuration. -h, --help Print this usage information.

Available commands: analyze Analyze Dart code in a directory. compile Compile Dart to various formats. create Create a new Dart project. devtools Open DevTools (optionally connecting to an existing application). doc Generate API documentation for Dart projects. fix Apply automated fixes to Dart source code. format Idiomatically format Dart source code. info Show diagnostic information about the installed tooling. pub Work with packages. run Run a Dart program. test Run tests for a project.

Run "dart help " for more information about a command. See https://dart.dev/tools/dart-tool for detailed documentation.

medz commented 2 months ago

@lsxqer I'm investigating, Prisma + Windows + Bun I haven't reproduced it yet, it seems to be related to specific devices and settings.

But I know you followed the documentation step by step, I will look for more devices to find the problem, please wait for me.

medz commented 2 months ago

@lsxqer Can you provide me your Bun version number?

medz commented 2 months ago

orm: ^3.4.8

@lsxqer I noticed that your orm version number is 3.4.8. The problem is found, please change the version number to 5.0.5

medz commented 2 months ago

I don't know what happened, using dart pub add orm installed version 3.x by default! This is weird! Then I manually corrected the version number to 5.0.5 and it still worked!