EAS build Prebuild (config syncing) step not using environment variables

I am trying to build a standalone iOS app using:
ENVIRONEMENT=STAGING eas build -p ios --profile staging

Error in Prebuild step:

Prebuilding managed project
- Creating native project directories (./ios and ./android) and updating .gitignore
✔ Created native project
- Adding Metro bundler config
✔ Added Metro config.
- Updating your package.json scripts, dependencies, and main file
✔ Updated package.json and added index.js entry point for iOS and Android.
- Config syncing
[stderr] [08:36:29] ENOTSUP: operation not supported on socket, copyfile '/Users/expo/workingdir/build' -> '/Users/expo/workingdir/build/ios/AppName/GoogleService-Info.plist'
[stderr] [08:36:29] Error: ENOTSUP: operation not supported on socket, copyfile '/Users/expo/workingdir/build' -> '/Users/expo/workingdir/build/ios/AppName/GoogleService-Info.plist'
[stderr]     at Object.copyFileSync (fs.js:1991:3)
[stderr]     at setGoogleServicesFile (/usr/local/eas-build-worker/node_modules/@expo/config-plugins/src/ios/Google.ts:61:6)
[stderr]     at /usr/local/eas-build-worker/node_modules/@expo/config-plugins/src/ios/Google.ts:17:25
[stderr]     at action (/usr/local/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/core-plugins.ts:118:29)
[stderr]     at interceptingMod (/usr/local/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/core-plugins.ts:190:12)
[stderr]     at action (/usr/local/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/core-plugins.ts:119:14)
[stderr]     at action (/usr/local/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/compiler-plugins.ts:413:23)
[stderr]     at evalModsAsync (/usr/local/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/mod-compiler.ts:75:25)
[stderr]     at compileModsAsync (/usr/local/eas-build-worker/node_modules/@expo/config-plugins/src/plugins/mod-compiler.ts:17:10)
[stderr]     at configureManagedProjectAsync (/usr/local/eas-build-worker/node_modules/expo-cli/src/commands/eject/configureProjectAsync.ts:166:12)
[stderr]     at prebuildAsync (/usr/local/eas-build-worker/node_modules/expo-cli/src/commands/eject/prebuildAsync.ts:89:25)
[stderr]     at actionAsync (/usr/local/eas-build-worker/node_modules/expo-cli/src/commands/prebuild.ts:36:3)
[stderr]     at Command.<anonymous> (/usr/local/eas-build-worker/node_modules/expo-cli/src/exp.ts:350:7)
node exited with non-zero code: 1

eas.json:

...
      "staging": {
        "workflow": "managed",
        "distribution": "internal",
        "releaseChannel": "staging",
        "env": {
          "ENVIRONMENT": "STAGING"
        }
      },
...

app.config.ts:

...
    'ios': {
      ...
      'googleServicesFile': process.env.ENVIRONEMENT === 'PROD' ? './GoogleService-Info.plist' : process.env.ENVIRONEMENT === 'STAGING' ? './GoogleService-Info-staging.plist' : '',
      ...
    },
...

I’m trying to have a different googleServicesFile for PROD and STAGING profile/env.

The issue seems to be that in the Prebuild step it will not have a googleServicesFile defined as process.env.ENVIRONEMENT is not set.

Is there a way to achieve this?

Note:
The App builds successfully if I just set googleServicesFile to ./GoogleService-Info-staging.plist.

process.env.ENVIRONEMENT - typo. should be process.env.ENVIRONMENT according to your env config

@notbrent
Thanks for your quick answer. I can’t believe I missed that and spend the whole day trying everything possible to fix it.

1 Like