Invalid Environment Variables

I am having an issue with accessing my ENVs within my drizzle.config.ts. I'm getting an error about invalid env variables despite them being present and being destructured in the env.mjs Each ENV is listed in the .env wrapped in single quotes.
10 Replies
JudgeJLo
JudgeJLo12mo ago
More context: it seems the db:push is being registered as trying to use server envs on the client.
Gravy
Gravy12mo ago
Hi, can you paste the error output in a code block?
JudgeJLo
JudgeJLo12mo ago
docdb-next@0.1.0 db:push drizzle-kit push:mysql --config=./drizzle.config.ts
drizzle-kit: v0.19.1
drizzle-orm: v0.27.0

Reading config file '/Users/jasonlong-hrf/HumanRightFirstDev/docdb/docdb-next/drizzle.config.ts'
:x: Invalid environment variables: {
NODE_ENV: [ 'Required' ],
DATABASE_CONNECTION_STRING: [ 'Required' ],
DATABASE_PASSWORD: [ 'Required' ],
DATABASE_URL: [ 'Required' ],
DATABASE_USERNAME: [ 'Required' ]
}
file:///Users/jasonlong-hrf/HumanRightFirstDev/docdb/docdb-next/node_modules/@t3-oss/env-nextjs/dist/index.mjs:1
import c from"zod";function l(e){let r=e.runtimeEnvStrict??e.runtimeEnv??process.env;if(e.skipValidation)return r;let a=typeof e.client=="object"?e.client:{},o=c.object(a),v=c.object(e.server),s=e.isServer??typeof window>"u",d=v.merge(o),i=s?d.safeParse(r):o.safeParse(r),f=e.onValidationError??(t=>{throw console.error("\u274C Invalid environment variables:",t.flatten().fieldErrors),new Error("Invalid environment variables")}),p=e.onInvalidAccess??(t=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")});return i.success===!1?f(i.error):new Proxy(i.data,{get(t,n){if(typeof n=="string")return!s&&!n.startsWith(e.clientPrefix)?p(n):t[n]}})}var u="NEXT_PUBLIC_";function C({runtimeEnv:e,...r}){return l({...r,clientPrefix:u,runtimeEnvStrict:e})}export{C as createEnv};

Error: Invalid environment variables
drizzle-kit: v0.19.1
drizzle-orm: v0.27.0

Reading config file '/Users/jasonlong-hrf/HumanRightFirstDev/docdb/docdb-next/drizzle.config.ts'
:x: Invalid environment variables: {
NODE_ENV: [ 'Required' ],
DATABASE_CONNECTION_STRING: [ 'Required' ],
DATABASE_PASSWORD: [ 'Required' ],
DATABASE_URL: [ 'Required' ],
DATABASE_USERNAME: [ 'Required' ]
}
file:///Users/jasonlong-hrf/HumanRightFirstDev/docdb/docdb-next/node_modules/@t3-oss/env-nextjs/dist/index.mjs:1
import c from"zod";function l(e){let r=e.runtimeEnvStrict??e.runtimeEnv??process.env;if(e.skipValidation)return r;let a=typeof e.client=="object"?e.client:{},o=c.object(a),v=c.object(e.server),s=e.isServer??typeof window>"u",d=v.merge(o),i=s?d.safeParse(r):o.safeParse(r),f=e.onValidationError??(t=>{throw console.error("\u274C Invalid environment variables:",t.flatten().fieldErrors),new Error("Invalid environment variables")}),p=e.onInvalidAccess??(t=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")});return i.success===!1?f(i.error):new Proxy(i.data,{get(t,n){if(typeof n=="string")return!s&&!n.startsWith(e.clientPrefix)?p(n):t[n]}})}var u="NEXT_PUBLIC_";function C({runtimeEnv:e,...r}){return l({...r,clientPrefix:u,runtimeEnvStrict:e})}export{C as createEnv};

Error: Invalid environment variables
Gravy
Gravy12mo ago
Attempted to access a server-side environment variable on the client, drizzle is set up for the client somehwo
JudgeJLo
JudgeJLo12mo ago
That's awkward. I explicitly don't want to expose my connection string lol Shouldn't my flag about skipping validation turn this off though? And I don't it the error on app run, just this function It has to be an issue with the envs themselves. I prefixed it with Next_Public and I'm still getting the exact same issues.
Gravy
Gravy12mo ago
try deleting node modules and pruning npm/yarn/pnpm store works for me
JudgeJLo
JudgeJLo12mo ago
Yeah, still no dice.
Gravy
Gravy12mo ago
if it should be public make sure to put it in the client object
JudgeJLo
JudgeJLo12mo ago
The maintainers tell me that I should import the ENV directly using dotenv in the config.
Coded_58
Coded_586mo ago
facing same issue
No description