I have environment variables set using the forge set command. I don’t know what I’ve missed that cause the error in the attached photo when deploying in development. I just followed the steps on the docs but I think I missed something. Please Help.
It might help if you shared the relevant parts of your manifest (the declaration and use of the variables).
Hi @TristanJayJVirtudazo
It seems like you might be trying to lint or tunnel your app locally, but the environment variables might not be set up yet. I’d suggest double-checking this part: Forge Tunnel and Environments. That should help clear things up!
Hi @AndreiPisklenov
I prefixed the env variables with FORGE_USER_VAR_ but I still get the same error. Here are some snaps
I forgot to mention that i use the variables inside the manifest file
Hey @TristanJayJVirtudazo ,
It looks like you’ve defined the environments in Forge, rather than exports within your local environment.
At the moment, environment variables which are added to the Forge manifest will only pull variables which have been defined locally for the CLI which is running forge deploy
like export CM_WSURL=wss://url.ngrok-free.app
.
The Forge Variables which you’ve set are only accessible in the Forge runtime for that environment.
Hi @SeanBourke
Thank you for the hasty response. Quick question, is this scenario for local development? and when deploying the app to staging or prod, will the env variables set be used for the manifest file?
The environment variables will be utilised for any environment you deploy to - they will pull from whatever your local env looks like. If you’re deploying via a pipeline, you may override these - alternatively, you’d need to update them locally.
Correct me if I’m wrong.
So if I’m going to deploy it to production I wouldn’t need to explicitly export the environment variables for the manifest to use right? (Assume that I’m not going to use a pipeline)
When using the manifest environment variables, prior to running commands like install
, deploy
or lint
, the CLI will interpolate the environment variables you have listed in your manifest with the corresponding environment variables exported/available in the environment that the CLI is running in. This is done irrespective of the Forge environment that you are deploying to like development, staging or production.
So if you have an environment variable like APP_ID
exported in your pipeline and also defined in your manifest and for your app id, then when running forge deploy
, it will use that environment variable when deploying.
Does that answer your question?