Jules
Jules3w ago

Can't start local development deployment due to missing environment variable

Hi, we would like to get local development deployments working for our repository in order to easily spawn background agents. Regular development deployments work well, but when I try to run npx convex dev --local --once I get the following error:
$ npx convex dev --local --once
✔ Started running a deployment locally at http://127.0.0.1:3210 and saved its name as CONVEX_DEPLOYMENT to .env.local

Write your Convex functions in convex/
Give us feedback at https://convex.dev/community or support@convex.dev
View the Convex dashboard at https://dashboard.convex.dev/d/<...>

✖ Error: Unable to start push to http://127.0.0.1:3210
✖ Error fetching POST http://127.0.0.1:3210/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Uncaught Failed to analyze _deps/node/37HDJG35.js: <ENV_VAR> environment variable is required
at <anonymous> (../../../../shared/src/sandbox/csb/sdk-patched.ts:22:56)
$ npx convex dev --local --once
✔ Started running a deployment locally at http://127.0.0.1:3210 and saved its name as CONVEX_DEPLOYMENT to .env.local

Write your Convex functions in convex/
Give us feedback at https://convex.dev/community or support@convex.dev
View the Convex dashboard at https://dashboard.convex.dev/d/<...>

✖ Error: Unable to start push to http://127.0.0.1:3210
✖ Error fetching POST http://127.0.0.1:3210/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Uncaught Failed to analyze _deps/node/37HDJG35.js: <ENV_VAR> environment variable is required
at <anonymous> (../../../../shared/src/sandbox/csb/sdk-patched.ts:22:56)
Looking at this module, the code that's causing this is
if (!process.env.<ENV_VAR>) {
...
}
if (!process.env.<ENV_VAR>) {
...
}
which is located at the root of the module. This works fine in a cloud deployment, where it's possible to push the code first and after that set the environment variable. We will look into refactoring the code in order to also make it work with local development deployment, but it would be great if this could work the same as in cloud development deployments.
4 Replies
Convex Bot
Convex Bot3w ago
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!
Jules
JulesOP3w ago
Does this also apply to new local development deployments? Because we do have this environment variable set as a default
No description
Nicolas
Nicolas2w ago
Hi @Jules! I tried to reproduce your issue locally and I could make it work with the following actions: • Start a local dev server without --once • After you get the error message, use the npx convex env set command to set the missing environment variable • This unblocks convex dev Also I checked and “Default Environment Variables” are ignored by local dev deployments at the moment
Jules
JulesOP2w ago
Great thanks!

Did you find this page helpful?