Vercel System Environment Variables not loaded in development

Hi,

Suddenly when I pull environment variables from Vercel, system environment variables like VERCEL_ENV (and everything else) is missing when --environment is not preview or production.

I am running the latest version of Vercel CLI (41.0.2)

This used to work for a number of years, and we have a whole number of build tools using VERCEL_ENV to configure projects successfully. It is also mentioned in the Vercel documentation that these are available in all environments.

1 Like

Hi @zigavajdic, welcome to the Vercel Community!

As per the docs, the system variables are available in all environments on Vercel, which is different than using the Vercel CLI to pull the environment variables locally.

May I know when was the last time you pull VERCEL_ variables using the CLI successfully? Because it shouldn’t be possible.

Hi Anshuman,

I think based on the current state of the documentation, it is hard to infer that you only mean Vercel environments, and that development doesn’t imply the VERCEL CLI environment on a local machine. Also it seems this wasn’t always the case as per this open issue [cli] Removing VERCEL_ENV in vercel@34.2.0 is a breaking change · Issue #11633 · vercel/vercel · GitHub.

I can’t tell you exactly when it stopped working. Unfortunately I don’t know what my latest vercel version was before updating the CLI tool.


1 Like

Hi @zigavajdic, thanks for sharing the feedback about the docs. I’ll pass it along to the docs team. About the CLI pulling in the VERCEL_ envs, let me confirm with the team if there are alternatives.

1 Like

this is a regression from what previously worked with vercel cli and I would also add incredibly annoying and frustrating…

as of 28.10.1

it would respect the expose system variables and pull them down for development env vars

now in 41.7.3

it does not

not sure why. this is creating a mismatch between local development, preview and production for env variable and I don’t understand why vercel would want promote that experience

Hi @followbl,

Pulling down local VERCEL_ environment variables for local development was removed because customers would sometimes edit these values locally and find themselves in confusing situations. These prefix variables are intended to only exist once code is deployed to the platform or when running a local environment intended to simulate the platform with vercel dev.

If you run vercel dev, environment variables that are knowable at local runtime should be available as part of the running process (for example, process.env in Node).

You should have access to VERCEL_URL, VERCEL_REGION, NOW_REGION, VERCEL_ENV, VERCEL.

For production, preview and we still allow pulling these locally for customers who have custom build requirements:

vercel env pull --environment production
vercel build --prod
vercel deploy --prod

So they’ll have them as part of their build, although do note many of the values will not be set (because they’re only known at the moment of deployment).

If you can tell us a bit more about your use case of wanting these available locally for development outside of use with vercel dev we can offer some suggestions.

1 Like

just a difference of opinion.

I’ve abstracted it away now, but these are the only variables in the entire app that are treated differently than the other 50 others, just feels weird to not have the ability to mirror your local development env to what you have in a deployed environment…

makes managing this difference need to happen in the users head. not in env variables.