EAS Build doesn't reflect latest environment variables correctly

Hi, I’ve an issue with building my application thru eas build.

I’ve defined the .env with the 2 variables to determine the API URL for different environments. This was included in the previous eas builds and ignored the environment variables that I have defined in the eas.json. Then only did I realize it and add the .env ignore into .easignore.

.env

EXPO_PUBLIC_ID_URL=bmj…
EXPO_PUBLIC_API_URL=bmj…

eas.json

{
“cli”: {
“version”: “>= 3.16.0”,
“appVersionSource”: “remote”
},
“build”: {
“development”: {
“autoIncrement”: true,
“developmentClient”: true,
“distribution”: “internal”,
“channel”: “development”,
“env”: {
“EXPO_PUBLIC_ID_URL”: “bmj…”,
“EXPO_PUBLIC_API_URL”: “bmj…”
}
},
“preview”: {
“autoIncrement”: true,
“distribution”: “internal”,
“channel”: “preview”,
“env”: {
“EXPO_PUBLIC_ID_URL”: “uat…”,
“EXPO_PUBLIC_API_URL”: “uat…”
}
},
“production”: {
“autoIncrement”: true,
“distribution”: “internal”,
“channel”: “production”,
“env”: {
“EXPO_PUBLIC_ID_URL”: “id…”,
“EXPO_PUBLIC_API_URL”: “api…”
}
}
},
“submit”: {
“production”: {}
}
}

However, the build process still shows the previous value in the .env when I have already run for preview profile, with the command eas build --platform android --profile preview --clear-cache. This has caused me unable call the API URL in the preview build by eas build.

Application build is still showing old value

verify that your build archive doesn’t include the .env: https://expo.fyi/eas-build-archive
also verify if maybe you added this to secrets by accident at some point

check your “Spin up build environment” phase on the build page to see what variables/secrets are set

Hi @brents, I’ve confirmed both .gitignore and .easignore has added the ignore file for the .env. From my “Spin up build environment” it shows correctly, but when I tried to console out with dynamic config method, it still took the value from .env.

.gitignore
image

.easignore
image

“Spin up build environment”

Console out from “Prebuild”

if you have the file committed to git already you might need to remove it with git rm

note that you can likely reproduce this on another machine by cloning your repository and running it there - this is essentially what EAS Build does

Hi @brents, I’ve confirmed that the .env does not committed into git. Anywhere I’ve resolved this issue by deleting the .env file. Thanks for your help.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.