eas build --local not passing env variables to config plugins

All EAS Builds are successful, but after opening the app there is a native crash mentioning that CioSiteId is nil. App.config.js looks like this:

plugins: [
      [
        "expo-cio",
        {
          cioSiteId: process.env.CUSTOMERIO_SITE_ID,
          cioApiKey: process.env.CUSTOMERIO_API_KEY,
        },
      ],
]

There is an .env file on the project root folder with those values and many others, which are successfully recognized during the build process by EAS (SENTRY_ORG, SENTRY_PROJECT, SENTRY_AUTH_TOKEN, etc). By simply replacing “process.env.CUSTOMERIO_SITE_ID” and “process.env.CUSTOMERIO_API_KEY” for the hard-coded values the crash doesn’t happen anymore.

Remote builds work just fine using Expo Secrets. Is it a bug of eas local builds? I would like to avoid using these hard-coded values on app.config.js and use the local .env file instead.

In your post, please share:

  • managed workflow
  • eas-cli/0.54.1

Hi @erisvaldojunior

Is your .env file in .gitignore?

If so, the local build will not have access to it. The local build copies your code to a temporary directory before building it. When it does this, it excludes things mentioned in .gitignore.

I think there are a couple of ways around this:

One option would be to copy .gitignore to .easignore and then remove .env from .easignore. This would also have the effect of uploading your .env file to the EAS Build servers if you do a non-local build.

Another option would be to set the environment variables in your local environment before building. You could do that by adding export to the start of all of the definitions in .env. e.g.:

export CUSTOMERIO_SITE_ID=1234
export CUSTOMERIO_API_KEY=ABCdefGHI

Then, before building, source .env:

$ source .env
$ eas build --local [...]