Setting Local Development Environment Variables
I don't know how to set the environment variables for my local development environment, I am unable to get
bunx convex dev --local --once
to work because some application code requires valid environment variables. Is there a solve for this?5 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
You can set the variables on your dev deployment in the dashboard
my dashboard is not getting setup locally, it’s failing
i know how to do it in the dashboard but i need to set it before even running convex dev
so i want to know if there is a way for me to set the environment variables before i get to the dashboard even
support told me that i can use npx convex env - will try
So, I have tried but I am getting this error.
I'm not sure if this is my code, or if it's internal code. I have no idea what _deps/node/PPY4NFXC.js is, as I cannot view it.
Okay, my fault, my code, I missed a env.
So, one thing that I am still not understanding is that when I do
convex dev --local --once
for the first time, I cannot load envs at all. Not even from a file. I first need to get the local deployment up, and then i can set the environment variables. Am I understanding this correctly?
So I have a piece of code that is this:
At the top of files that require an ENV, i have this code:
When I thus run convex dev --local --once
it will never start the deployment locally, so I can never set these environment variables.So, I am an utter fool. Because the environment for my deployment needs to be configured inside the convex.dev dashboard. I see now that I have my macbook available there as an environment, where i can then add the environment variables.
I would suggest we update the documentation, to help guide me that when i do a
convex dev --local --once
it will render a new machine on convex.dev
for the project, so it won't just be production
and development
. You can then go in there and configure your environment variables.
I did not connect the dots with this, and was rather trying to use the .env.local do to this, which is wrong, by design I see.
https://docs.convex.dev/cli/local-deploymentsLocal Deployments for Development | Convex Developer Hub
Instead of syncing code to a Convex dev deployment hosted in the cloud, you can
npx convex set env
should still have worked for you, did it not?
And yeah, .env.local is used just for deployment info by the cli, the code in the deployment doesn't get env vars from that file. Have to be defined either via cli or dashboard.