R2 component shows missing env variables despite being set
I'm trying to use the R2 Component but am getting the folliwing error despite having set the requried variables in my dev env:
```✖ Error fetching POST https://fortunate-jay-356.convex.cloud/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Failed to analyze files.js: Uncaught Error: R2 configuration is missing required fields.
R2_BUCKET, R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY
at new R2 (../node_modules/@convex-dev/r2/src/client/index.ts:119:74)
at <anonymous> (../convex/files.ts:7:15)
6 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!
Just pushed 0.5.1, it will tell you exactly which variables are missing (previously just listed every required variable). Run
npx convex dashboard
from your project root to ensure you're looking at the right environment when checking env vars.Hey @erquhart , even if everything is set in the env.local file I get this error (local backend) Do you have a suggestion to debug this?
The latest shows a different error - it will tell you exactly which variables are undefined. Is it still all of them for you?
Also, you typed
env.local
, guessing that's just a typo, but make sure your file is named .env.local
, beginning with a dot (.).✖ 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:
Failed to analyze collections/landingPages/queries.js: Uncaught Error: R2 configuration is missing required fields:
Missing: R2_BUCKET, R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY
Yeah it was a typo 🙂
I mean the file is correct but somehow it can't read...
Setting with 'npx set...' worked. Thanks!
Oh what am I thinking, .env.local has deployment details for convex cli, but it won't populate env vars in your deployment. Those have to be set as you did, or in the dashboard.