drizzle-orm
drizzle-orm copied to clipboard
[BUG]: "ENOENT: no such file or directory, open '/home/myuser/.local/share/drizzle-studio/localhost-key.pem'" on generate:pg
What version of drizzle-orm are you using?
0.29.3
What version of drizzle-kit are you using?
From 0.20.9 to 0.20.14
Describe the Bug
From drizzle-kit 0.20.9 when I run the following command:
drizzle-kit generate:pg --schema=libs/shared/model/src/dbo.ts --out=apps/back-api/src/app/db/migrations
I get the following error:
(...)
[✓] Your SQL migration file ➜ apps/back-api/src/app/db/migrations/0000_peaceful_lizard.sql 🚀
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: ENOENT: no such file or directory, open '/home/myuser/.local/share/drizzle-studio/localhost-key.pem'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/home/myuser/.local/share/drizzle-studio/localhost-key.pem'
}
The generation itself seems to be finishing correctly.
Please note that I don't use drizzle-studio.
The generation works fine with drizzle-kit 0.20.8, it starts failing at 0.20.9 and is still failing in 0.20.14.
The /home/myuser/.local/share/drizzle-studio/ folder indeed exists, but it is empty, hence the fact that localhost-key.pem is not found.
Expected behavior
Generation finishes without error.
Environment & setup
Linux Manjaro
$ node --version
v20.11.0
$ npm --version
10.2.4
+1, reverting drizzle-kit to version 0.20.8 works
+1
I just added empty files localhost-key.pem and localhost.pem in the application support folder for drizzle and it seems to work ok without any valid pem's
How has this not been solved yet? Doesn't everyone run into this issue on first using the library?
i was facing the same issue. this fix it for me
import { Env } from '@/utils/env'
import { drizzle } from 'drizzle-orm/postgres-js'
import { migrate } from 'drizzle-orm/postgres-js/migrator'
import postgres from 'postgres'
const migrationClient = postgres(Env.DATABASE_URL as string, { max: 1 })
const db = drizzle(migrationClient) // this line fixed the issue
async function startMigration() {
await migrate(db, { migrationsFolder: 'src/database/migrations' })
await migrationClient.end()
}
startMigration()
I use sudo drizzle-kit generate then work