Error: Serverless Function runtime provided.al2023 does not support more than 4KB for environment variables
I get this error when trying to build my Rust project on the free tier in the cloud, but it works fine on my machine with vercel dev. I do not use environment variables at all, and I have disabled Automatically expose System Environment Variables.
This happens because Vercel always includes system env vars, even if you’ve turned off “Automatically expose System Environment Variables.” The Rust runtime has a 4KB limit for env vars, and those system vars can push you over.
You can try updating to the latest Rust runtime instead of pinning to 4.0.9:
Also double-check your project settings in the Vercel dashboard for any hidden env vars that may have been added automatically. If none of these help, you may need to restructure your functions or consider a different deployment approach.
Also seeing this error for a project whose builds started failing out of the blue. Un-checking the “Automatically expose System Environment Variables” box does not work either.
I also started seeing these unexpectedly when a previous function was working correctly, now it is not. There might be something that the maintainers of the community run time can do.
I also wonder if Vercel intends to officially support a Rust runtime that has the same 64kb limit that other officially supported runtimes do.