Environment Variables are returning undefined

royangerPRO

9 months ago

I started getting this issue several days ago but I hadn't had time to look into it until now. Suddenly all builds are failing for either service in the project indicating that the env vars are not valid.

I ended up adding the following to one of the apps to see what was happening:

console.log('CLERK_BOT_ACTIVE', process.env.CLERK_BOT_ACTIVE)
console.log('CLERK_BOT_TOKEN', process.env.CLERK_BOT_TOKEN)
console.log('DISCORD_FORUM', process.env.DISCORD_FORUM)
console.log('DISCORD_SERVER_ID', process.env.DISCORD_SERVER_ID)
console.log('CLERK_BOT_CLIENT_ID', process.env.CLERK_BOT_CLIENT_ID)
console.log('DATABASE_URL', process.env.DATABASE_URL)
console.log('CLERK_BOT_TAG_NEW', process.env.CLERK_BOT_TAG_NEW)
console.log('CLERK_BOT_TAG_INVESTIGATING', process.env.CLERK_BOT_TAG_INVESTIGATING)
console.log('CLERK_BOT_TAG_RESOLVED', process.env.CLERK_BOT_TAG_RESOLVED)
console.log('CLERK_BOT_TAG_CLOSED', process.env.CLERK_BOT_TAG_CLOSED)
console.log('CLERK_BOT_TAG_ENGINEERING', process.env.CLERK_BOT_TAG_ENGINEERING)
console.log('SENTRY_DSN', process.env.SENTRY_DSN)
console.log('ENVIRONMENT', process.env.ENVIRONMENT)
console.log('PLAIN_API_KEY', process.env.PLAIN_API_KEY)
console.log('DASHBOARD_URL', process.env.DASHBOARD_URL)
console.log('CLERK_BOT_STAFF_ROLES', process.env.CLERK_BOT_STAFF_ROLES)

In the deploy logs I see the following:

clerk-bot:start: CLERK_BOT_ACTIVE undefined
clerk-bot:start: CLERK_BOT_TOKEN undefined
clerk-bot:start: DISCORD_FORUM undefined
clerk-bot:start: DISCORD_SERVER_ID undefined
clerk-bot:start: CLERK_BOT_CLIENT_ID undefined
clerk-bot:start: DATABASE_URL undefined
clerk-bot:start: CLERK_BOT_TAG_NEW undefined
clerk-bot:start: CLERK_BOT_TAG_INVESTIGATING undefined
clerk-bot:start: CLERK_BOT_TAG_RESOLVED undefined
clerk-bot:start: CLERK_BOT_TAG_CLOSED undefined
clerk-bot:start: CLERK_BOT_TAG_ENGINEERING undefined
clerk-bot:start: SENTRY_DSN undefined
clerk-bot:start: ENVIRONMENT undefined
clerk-bot:start: PLAIN_API_KEY undefined
clerk-bot:start: DASHBOARD_URL undefined
clerk-bot:start: CLERK_BOT_STAFF_ROLES undefined

If I check the Settings -> Variables section for one of the PRs that are failing with this issue all 16 variables are present with values.

The only things that I recall changing around that time were upgrading bun which runs the two Discord bots but I're tried downgrading that, and that I deleted the staging branch from the repo but kept the environment in Railway.

0 Replies

royangerPRO

9 months ago

5699151a-d2d8-47c5-9c29-35462dd2497f


9 months ago

are you perhaps using turbo?


royangerPRO

9 months ago

Yes, indeed.


royangerPRO

9 months ago

And I think I upgraded. Is that it?


9 months ago

yes, indeed, please read their docs page -


royangerPRO

9 months ago

That's new with turbo 2? I totally missed that. I wouldn't have guessed turbo was the cause here.


9 months ago

not sure what version uses strict mode by default but yeah that's the issue, you aren't the first person to report missing environment variables


royangerPRO

9 months ago

I figured it was going to be something like that, but I was definitely confused. Looking at turbo, I was on 1.13.4 and that's the last 1.x version so its definitely something in 2.


royangerPRO

9 months ago

I just test loose mode and that's working, so that was 100% it. Thanks for the super fast response. I appreciate it.


9 months ago

no problem!