drizzle-orm icon indicating copy to clipboard operation
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

Open Ciferlingvulo opened this issue 1 year ago • 5 comments

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

Ciferlingvulo avatar Feb 10 '24 17:02 Ciferlingvulo

+1, reverting drizzle-kit to version 0.20.8 works

diegoalzate avatar Feb 16 '24 21:02 diegoalzate

+1

kimdanielarthur-cowlabs avatar Feb 22 '24 10:02 kimdanielarthur-cowlabs

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

kimdanielarthur-cowlabs avatar Feb 22 '24 12:02 kimdanielarthur-cowlabs

How has this not been solved yet? Doesn't everyone run into this issue on first using the library?

jckw avatar May 11 '24 10:05 jckw

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()

Felix-Asante avatar May 25 '24 12:05 Felix-Asante

I use sudo drizzle-kit generate then work

Adherentman avatar Sep 03 '24 14:09 Adherentman