Summary
orm init scaffolds prisma.config.ts with a relative contract path:
orm: ormConfig({
contract: "./src/prisma/contract.prisma",
db: { connection: process.env['DATABASE_URL']! },
}),
With that config, contract emit crashes:
CLI.UNEXPECTED: The argument 'filename' must be a file URL object, file URL string, or absolute path
string. Received './src/prisma/package.json' (ERR_INVALID_ARG_VALUE)
Changing the config to an absolute path (new URL('./src/prisma/contract.prisma', import.meta.url).pathname) makes the same command succeed and emit contract.json/contract.d.ts normally.
Where it breaks
In @prisma/orm-toolchain@8.0.0-rc.2 (dist ref-*.mjs), validateContractDeps does:
const resolve = createRequire(`${projectRoot}/package.json`);
and projectRoot arrives as the relative ./src/prisma derived from the config's contract path, but node:module's createRequire requires an absolute path or file URL. Either the config loader should absolutize contract against the config file's directory before handing it to the toolchain, or the toolchain should resolve projectRoot to an absolute path itself.
Filing here because the repro is entirely through prisma-cli commands and the config loader (cli-engine loadConfig) may be the layer that should absolutize; transfer to the ORM repo if it's purely an orm-toolchain fix.
Repro caveat
Reproduced on macOS / Node 24.11.1 with the rc.4 CLI shell and a locally patched @prisma/cli-engine built from repo HEAD, because the published engine crashes the CLI at startup (#202). I could not verify against a fully published stack for that reason. Today users hit this bug's surface anyway: orm init's final emit step fails with CLI.INIT_EMIT_FAILED due to #202, and once that is fixed, this crash is the next thing the default scaffold + contract emit flow runs into (unless the published engine absolutizes the path where the HEAD engine does not).
Found while validating the docs quickstart end to end (prisma/web#8151).
🤖 Filed with Claude Code on behalf of datta@prisma.io
Summary
orm initscaffoldsprisma.config.tswith a relative contract path:With that config,
contract emitcrashes:Changing the config to an absolute path (
new URL('./src/prisma/contract.prisma', import.meta.url).pathname) makes the same command succeed and emitcontract.json/contract.d.tsnormally.Where it breaks
In
@prisma/orm-toolchain@8.0.0-rc.2(distref-*.mjs),validateContractDepsdoes:and
projectRootarrives as the relative./src/prismaderived from the config's contract path, butnode:module'screateRequirerequires an absolute path or file URL. Either the config loader should absolutizecontractagainst the config file's directory before handing it to the toolchain, or the toolchain should resolveprojectRootto an absolute path itself.Filing here because the repro is entirely through prisma-cli commands and the config loader (cli-engine
loadConfig) may be the layer that should absolutize; transfer to the ORM repo if it's purely an orm-toolchain fix.Repro caveat
Reproduced on macOS / Node 24.11.1 with the rc.4 CLI shell and a locally patched
@prisma/cli-enginebuilt from repo HEAD, because the published engine crashes the CLI at startup (#202). I could not verify against a fully published stack for that reason. Today users hit this bug's surface anyway:orm init's final emit step fails withCLI.INIT_EMIT_FAILEDdue to #202, and once that is fixed, this crash is the next thing the default scaffold +contract emitflow runs into (unless the published engine absolutizes the path where the HEAD engine does not).Found while validating the docs quickstart end to end (prisma/web#8151).
🤖 Filed with Claude Code on behalf of datta@prisma.io