P1012: Env var not found in predeploy
xeno
HOBBYOP

a month ago

```web:build: Prisma schema loaded from prisma/schema.prisma
web:build: Error: Prisma schema validation - (get-config wasm)
web:build: Error code: P1012
web:build: error: Environment variable not found: DATABASE_URL.

web:build: --> prisma/schema.prisma:8
web:build: |
web:build: 7 | provider = "mysql"
web:build: 8 | url = env("DATABASE_URL")
web:build: |
web:build:
web:build: Validation Error Count: 1```

I'm getting this issue with my predeploy command. The env var is definitely there. I've verified that much.

Any ideas? Where is it even getting the pnpm run build from?

railway.toml

[build]
builder = "railpack"

[deploy]
predeployCommand = ["pnpm install --frozen-lockfile && pnpm --filter @repo/db exec prisma generate && pnpm --filter @repo/db exec prisma migrate deploy && pnpm --filter web run build"]
startCommand = "cd apps/web && pnpm start"
restartPolicyType = "on_failure"
restartPolicyMaxRetries = 10

[healthcheck]
path = "/api/health"
timeout = 100
interval = 60

Log Files

[Region: us-east4]

╭────────────────╮
│ Railpack 0.9.2 │
╰────────────────╯

↳ Detected Node
↳ Using pnpm package manager
↳ Found workspace with 2 packages
↳ Installing pnpm@9.15.4 with Corepack

Packages
──────────
pnpm  │  9.15.4   │  package.json > packageManager (9.15.4)
node  │  18.20.8  │  package.json > engines > node (>=18)

Steps
──────────
▸ install
$ npm i -g corepack@latest && corepack enable && corepack prepare --activate
$ pnpm install

▸ build
$ pnpm run build

Deploy
──────────
$ cd apps/web && pnpm start


Successfully prepared Railpack plan for build


context: m9jf-upjk

load build definition from railpack-plan.json
0ms

install mise packages: node
2s
mise node@18.20.8 ✓ installed

copy / /app, package.json
204ms

npm i -g corepack@latest && corepack enable && corepack prepare --activate
2s
Preparing pnpm@9.15.4 for immediate activation...

copy /mise/shims, /mise/installs, /usr/local/bin/mise, /etc/mise/config.toml, /root/.local/state/mise
1s

mkdir -p /app/node_modules/.cache
929ms

pnpm install
39s
Done in 38.6s

copy / /app
785ms

pnpm run build
5s
> travelbreeze-monorepo@0.0.1 build /app
> turbo run build
$10 Bounty

0 Replies

passos
MODERATOR

a month ago

Hey, I see that you're using Turborepo. Make sure that your database environment variable is specified in the turbo.json config file.


iloveitaly
HOBBY

a month ago

@ThallesComH I'm not too familiar with TurboRepo. Why do we need to define the database environment variable there? Feel free to just push me to some documentation if that's easier.


passos
MODERATOR

a month ago

Turborepo caches everything it can, but when environment variables change, a build command for example may behave non-deterministically, creating issues when sharing the cache.


passos
MODERATOR

a month ago

More issues that can occur are described in the red warning box here. Even ways of going YOLO and disabling the need of it
https://turborepo.com/docs/crafting-your-repository/using-environment-variables


iloveitaly
HOBBY

a month ago

Awesome, this is helpful, thanks!


Loading...