drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.78k stars 658 forks source link

[BUG]: ENOENT error on subsequent runs with absolute path in 'out' config #1583

Open NurramoX opened 1 year ago

NurramoX commented 1 year ago

What version of drizzle-orm are you using?

0.29.1

What version of drizzle-kit are you using?

0.20.6

Describe the Bug

Issue: When using an absolute path in the drizzle.config.ts for the out property, the first run of drizzle-kit generate:sqlite completes successfully, generating the SQL migration file. However, any subsequent runs throw me

Error: ENOENT: no such file or directory, open './/home/ramzan/Projects/CDF/drizzle/meta/0000_snapshot.json'

Steps to Reproduce:

  1. Define the drizzle.config.ts with an absolute path for the out property:

    import type {Config} from "drizzle-kit";
    
    export default {
        schema: "./migrations/schema.ts",
        out: "/home/ramzan/Projects/CDF/drizzle"
    } satisfies Config;
  2. Run npx drizzle-kit generate:sqlite. It executes correctly the first time.
  3. Run npx drizzle-kit generate:sqlite again without changing any config.

Expected behavior

Expected Behavior: The tool should recognize the absolute path on subsequent runs and correctly reference the generated meta/0000_snapshot.json file.

Actual Behavior: The second run prepends an additional ./ to the absolute path, causing the file lookup to fail

Environment & setup

breathingcyborg commented 10 months ago

I'm facing the same issue when using generate:pg.

mattfysh commented 8 months ago

in the meantime i'm using out: path.relative(process.cwd(), '/absolute/path/to/config')

iursevla commented 8 months ago

+1 still persists in latests version

drizzle-kit: v0.20.14
drizzle-orm: v0.30.6

in the meantime i'm using out: path.relative(process.cwd(), '/absolute/path/to/config')

Thanks @mattfysh. This worked

francisbrito commented 7 months ago
drizzle-kit: v0.20.17
drizzle-orm: v0.30.10

I can confirm the issue persist and that, as noted above, @mattfysh's work around fixes the issue.

hmidmrii commented 1 month ago

It's blocking me on windows, I'm going to create a PR to fix it, this is the line that needs update