OpenCut-app / OpenCut-app/OpenCut

[BUG] error: script "db:migrate" exited with code 1

Open
#304 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
89.8k
Forks
8.9k
PR merge metrics
No merged PRs in 30d

Description

Platform

windows 11

Browser

chrome

Current Behavior

the error im getting:

C:\Users\ASUS\Documents\GitHub\OpenCut\apps\web>bun run db:migrate
$ drizzle-kit migrate
No config path provided, using default 'drizzle.config.ts'
Reading config file 'C:\Users\ASUS\Documents\GitHub\OpenCut\apps\web\drizzle.config.ts'
❌ Invalid environment variables: [
  {
    expected: 'string',
    code: 'invalid_type',
    path: [ 'BETTER_AUTH_SECRET' ],
    message: 'Invalid input: expected string, received undefined'
  },
  {
    expected: 'string',
    code: 'invalid_type',
    path: [ 'NEXT_PUBLIC_BETTER_AUTH_URL' ],
    message: 'Invalid input: expected string, received undefined'
  }
]
Invalid environment variables
error: script "db:migrate" exited with code 1

docker is able to run and opens up healthy

C:\Users\ASUS\Documents\GitHub\OpenCut>cd web/apps
The system cannot find the path specified.

C:\Users\ASUS\Documents\GitHub\OpenCut>cd apps/web

C:\Users\ASUS\Documents\GitHub\OpenCut\apps\web>docker-compose up -d
[+] Running 4/4
 ✔ Container opencut-redis-1                  Healthy                                                              1.0s
 ✔ Container opencut-db-1                     Healthy                                                              1.5s
 ✔ Container opencut-serverless-redis-http-1  Healthy                                                              1.5s
 ✔ Container opencut-web-1                    Started                                                              1.7s

i amended both env.local (first) then env.example to see if that did anything here is the layout of both of the files:

# Database (matches docker-compose.yaml)
DATABASE_URL="postgresql://opencut:opencutthegoat@localhost:5432/opencut"

# Generate a secure secret for Better Auth
BETTER_AUTH_SECRET="f9c0403dc4a0369cac83451b589e50fd"
BETTER_AUTH_URL="http://localhost:3000"

# Redis (matches docker-compose.yaml)
UPSTASH_REDIS_REST_URL="http://localhost:8079"
UPSTASH_REDIS_REST_TOKEN="example_token"

# Development
NODE_ENV="development"

if i try bun run dev instead of bun run db:migrate and then open localhost:3000 it throws this error

C:\Users\ASUS\Documents\GitHub\OpenCut\apps\web>bun run dev
$ next dev
   ▲ Next.js 15.4.1
   - Local:        http://localhost:3000
   - Network:      http://172.17.192.1:3000
   - Environments: .env.local

 ✓ Starting...
 ✓ Ready in 1734ms
 ○ Compiling /middleware ...
 ✓ Compiled /middleware in 816ms (190 modules)
❌ Invalid environment variables: [
  {
  expected: 'string',
  code: 'invalid_type',
  path: [ 'NEXT_PUBLIC_BETTER_AUTH_URL' ],
  message: 'Invalid input'
}
]
 ⨯ Error: Invalid environment variables
    at keys (..\..\packages\auth\src\keys.ts:5:12)
    at eval (src\env.ts:8:26)
    at (middleware)/./src/env.ts (.next\server\middleware.js:1301:1)
    at __webpack_require__ (.next\server\edge-runtime-webpack.js:37:33)
    at fn (.next\server\edge-runtime-webpack.js:273:21)
    at eval (webpack-internal:///(middleware)/./src/middleware.ts:7:62)
    at (middleware)/./src/middleware.ts (.next\server\middleware.js:1312:1)
  3 |
  4 | export const keys = () =>
> 5 |   createEnv({
    |            ^
  6 |     server: {
  7 |       BETTER_AUTH_SECRET: z.string(),
  8 |     },
 ○ Compiling /_error ...
Watchpack Error (initial scan): Error: EINVAL: invalid argument, lstat 'C:\DumpStack.log.tmp'
Watchpack Error (initial scan): Error: EINVAL: invalid argument, lstat 'C:\hiberfil.sys'
Watchpack Error (initial scan): Error: EINVAL: invalid argument, lstat 'C:\pagefile.sys'
Watchpack Error (initial scan): Error: EINVAL: invalid argument, lstat 'C:\swapfile.sys'
<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (128kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
 ✓ Compiled /_error in 1348ms (362 modules)
Watchpack Error (initial scan): Error: EINVAL: invalid argument, lstat 'C:\DumpStack.log.tmp'
Watchpack Error (initial scan): Error: EINVAL: invalid argument, lstat 'C:\hiberfil.sys'
Watchpack Error (initial scan): Error: EINVAL: invalid argument, lstat 'C:\swapfile.sys'
Watchpack Error (initial scan): Error: EINVAL: invalid argument, lstat 'C:\pagefile.sys'
 GET / 404 in 4ms
 ○ Compiling /_not-found ...
 ⚠ Fast Refresh had to perform a full reload due to a runtime error.
❌ Invalid environment variables: [
  {
  expected: 'string',
  code: 'invalid_type',
  path: [ 'NEXT_PUBLIC_BETTER_AUTH_URL' ],
  message: 'Invalid input'
}
]
 ⨯ Error: Invalid environment variables
    at keys (..\..\packages\auth\src\keys.ts:5:12)
    at eval (src\env.ts:8:26)
    at (middleware)/./src/env.ts (.next\server\middleware.js:1301:1)
    at __webpack_require__ (.next\server\edge-runtime-webpack.js:37:33)
    at fn (.next\server\edge-runtime-webpack.js:273:21)
    at eval (webpack-internal:///(middleware)/./src/middleware.ts:7:62)
    at (middleware)/./src/middleware.ts (.next\server\middleware.js:1312:1)
  3 |
  4 | export const keys = () =>
> 5 |   createEnv({
    |            ^
  6 |     server: {
  7 |       BETTER_AUTH_SECRET: z.string(),
  8 |     },
 ✓ Compiled /_not-found in 7.1s (1138 modules)
❌ Invalid environment variables: [
  {
  expected: 'string',
  code: 'invalid_type',
  path: [ 'NEXT_PUBLIC_BETTER_AUTH_URL' ],
  message: 'Invalid input'
}
]
 ⨯ Error: Invalid environment variables
    at keys (..\..\packages\auth\src\keys.ts:5:12)
    at eval (src\env.ts:8:26)
    at (middleware)/./src/env.ts (.next\server\middleware.js:1301:1)
    at __webpack_require__ (.next\server\edge-runtime-webpack.js:37:33)
    at fn (.next\server\edge-runtime-webpack.js:273:21)
    at eval (webpack-internal:///(middleware)/./src/middleware.ts:7:62)
    at (middleware)/./src/middleware.ts (.next\server\middleware.js:1312:1)
  3 |
  4 | export const keys = () =>
> 5 |   createEnv({
    |            ^
  6 |     server: {
  7 |       BETTER_AUTH_SECRET: z.string(),
  8 |     },
 ⚠ Fast Refresh had to perform a full reload due to a runtime error.
❌ Invalid environment variables: [
  {
  expected: 'string',
  code: 'invalid_type',
  path: [ 'NEXT_PUBLIC_BETTER_AUTH_URL' ],
  message: 'Invalid input'
}
]
 ⨯ Error: Invalid environment variables
    at keys (..\..\packages\auth\src\keys.ts:5:12)
    at eval (src\env.ts:8:26)
    at (middleware)/./src/env.ts (.next\server\middleware.js:1301:1)
    at __webpack_require__ (.next\server\edge-runtime-webpack.js:37:33)
    at fn (.next\server\edge-runtime-webpack.js:273:21)
    at eval (webpack-internal:///(middleware)/./src/middleware.ts:7:62)
    at (middleware)/./src/middleware.ts (.next\server\middleware.js:1312:1)
  3 |
  4 | export const keys = () =>
> 5 |   createEnv({
    |            ^
  6 |     server: {
  7 |       BETTER_AUTH_SECRET: z.string(),
  8 |     },
 GET / 404 in 2ms

local host:3000 is showing this if i just run bun run dev and open localhost:3000, not bun run db:migrate

 
 3 |
  4 | export const keys = () =>
> 5 |   createEnv({
    |            ^
  6 |     server: {
  7 |       BETTER_AUTH_SECRET: z.string(),
  8 |     },

Call Stack

11

Hide 3 ignore-listed frame(s)
<unknown>
file:///C:/Users/ASUS/Documents/GitHub/OpenCut/node_modules/%20(t3-oss/env-core/dist/src-Bb3GbGAa.js (54)
eval
..\..\node_modules\@t3-oss\env-core\dist\src-Bb3GbGAa.js (54:1)
createEnv
..\..\node_modules\@t3-oss\env-core\dist\src-Bb3GbGAa.js (59:1)
createEnv
..\..\node_modules\@t3-oss\env-nextjs\dist\index.js (16:20)
keys
..\..\packages\auth\src\keys.ts (5:12)
eval
src\env.ts (8:27)
(middleware)/./src/env.ts
.next\server\middleware.js (1301:1)
__webpack_require__
.next\server\edge-runtime-webpack.js (37:33)
fn
.next\server\edge-runtime-webpack.js (273:21)
eval
./src/middleware.ts
(middleware)/./src/middleware.ts
.next\server\middleware.js (1312:1)
Expected Behavior

No response

Recurrence Probability

Always

Steps To Reproduce

set env.local to

Database (matches docker-compose.yaml)

DATABASE_URL="postgresql://opencut:opencutthegoat@localhost:5432/opencut"

Generate a secure secret for Better Auth

BETTER_AUTH_SECRET="f9c0403dc4a0369cac83451b589e50fd"
BETTER_AUTH_URL="http://localhost:3000"

Redis (matches docker-compose.yaml)

UPSTASH_REDIS_REST_URL="http://localhost:8079"
UPSTASH_REDIS_REST_TOKEN="example_token"

Development

NODE_ENV="development"

due to it asking for a string ive tried for the BETTER_AUTH_SECRET both of these:
BETTER_AUTH_SECRET="f9c0403dc4a0369cac83451b589e50fd"
BETTER_AUTH_SECRET="123131235253245"

ive also tried it with env. example copied exactly as local and default error is still persisting

Anything else?

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/auth/src/keys.ts, apps/web/src/env.ts, and drizzle.config.ts, then compare the environment variable names reported by the logs with those in the provided env files. Run bun run db:migrate and bun run dev on Windows after checking the configuration; done means both commands pass environment validation without the reported errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, docker, nextjs, postgresql, redis, typescript
Domain
authentication, database, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.