eas-cli icon indicating copy to clipboard operation
eas-cli copied to clipboard

eas update appears to be changing an environment variable in my build

Open HM-23-HM opened this issue 1 year ago • 12 comments

Build/Submit details page URL

https://expo.dev/accounts/hodeem/projects/sheltah/builds/7eb6fb53-0f9a-4ba0-b00d-cba0834d947d

Summary

I have SERVER set in both the local .env file and the eas.json file. The .env file is in the .gitignore file. In the JS code, the SERVER value is referenced by using const SERVER = process.env.SERVER.

If I run eas build with a profile, platform etc., the JS code uses the correct SERVER value from selected build profile.

However, when I run eas update, the JS code intermittently uses the SERVER value that I only have in the local .env file.

I say "intermittently" because it appears that the change happens on the first eas update, but I can't change the SERVER value via. the .env file with any subsequent eas update. It has happened twice so far. Can someone let me know what I'm doing wrong or if this is a legitimate bug.

Managed or bare?

Managed

Environment

Output from npx expo-env-info:


  expo-env-info 1.2.0 environment info:
    System:
      OS: macOS 11.7.4
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 18.18.1 - ~/.nvm/versions/node/v18.18.1/bin/node
      Yarn: 1.22.19 - ~/.nvm/versions/node/v18.18.1/bin/yarn
      npm: 9.8.1 - ~/.nvm/versions/node/v18.18.1/bin/npm
      Watchman: 2023.08.28.00 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.15.2 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
    IDEs:
      Android Studio: 2022.1 AI-221.6008.13.2211.9514443
      Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
    npmPackages:
      @expo/metro-config: ~0.10.0 => 0.10.7 
      babel-preset-expo: ^9.5.2 => 9.5.2 
      expo: ^48 => 48.0.20 
      react: 18.2.0 => 18.2.0 
      react-native: 0.71.14 => 0.71.14 
      react-native-web: ~0.18.10 => 0.18.12 
    npmGlobalPackages:
      eas-cli: 7.2.0
    Expo Workflow: managed
    ```
    
    Output from `npx expo-doctor`:

✔ Check Expo config for common issues ✔ Check package.json for common issues ✔ Check dependencies for packages that should not be installed directly ✔ Check for common project setup issues ✔ Check for issues with metro config ✔ Check npm/ yarn versions ✔ Check Expo config (app.json/ app.config.js) schema ✔ Check that packages match versions required by installed Expo SDK ✔ Check for legacy global CLI installed locally ✔ Check that native modules do not use incompatible support packages ✔ Check that native modules use compatible support package versions for installed Expo SDK

Didn't find any issues with the project!


### Error output

N/A

### Reproducible demo or steps to reproduce from a blank project

1. Run `eas build --auto-submit --profile production --platform android`
2. Run `eas submit --channel production`

Files:
.env

SERVER=https://local-domain.com


.gitignore

node_modules/ .expo/ npm-debug.* *.jks *.p8 *.p12 *.key *.mobileprovision .orig. web-build/

macOS

.DS_Store

.env*

android/ ios/

@generated expo-cli sync-e7dcf75f4e856f7b6f3239b3f3a7dd614ee755a8

The following patterns were generated by expo-cli

OSX

.DS_Store

Xcode

build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata *.xccheckout *.moved-aside DerivedData *.hmap *.ipa *.xcuserstate project.xcworkspace

Android/IntelliJ

build/ .idea .gradle local.properties *.iml *.hprof

node.js

node_modules/ npm-debug.log yarn-error.log

BUCK

buck-out/ .buckd/ *.keystore !debug.keystore

Bundle artifacts

*.jsbundle

CocoaPods

/ios/Pods/

Expo

.expo/ web-build/ dist/

@end expo-cli

dont_upload/

*/Spring Boot **/build *.keystore *.apk

artifacts


eas.json

{ "cli": { "version": ">= 3.8.1", "appVersionSource": "remote" }, "build": { "internal": { "developmentClient": true, "distribution": "internal", "ios": { "simulator": true, "resourceClass": "m-medium", "cocoapods": "1.15.2" }, "android": { "developmentClient": true }, "channel": "development" }, "staging": { "distribution": "store", "ios": { "resourceClass": "m-medium", "cocoapods": "1.15.2", "autoIncrement": "buildNumber" }, "android": { "resourceClass": "medium", "buildType": "app-bundle", "autoIncrement": "versionCode" }, "channel": "staging", "env": { "SERVER": "https://staging-domain.com } }, "production": { "extends": "staging", "channel": "production", "env":{ "SERVER": "https://production-domain.com" } } }, "submit": { "production": { "android": { "serviceAccountKeyPath": "./dont_upload/google-service-account-key.json", "track": "production" }, "ios": { "appleId": "", "ascAppId": "", "appleTeamId": "***" } }, "staging": { "extends": "production", "android": { "track": "alpha" } } } }


app.config.js

module.exports = ({ config }) => ({ "expo": { "name": "", "scheme": "", "slug": "", "version": "1.0.1", "orientation": "portrait", "icon": "./assets/house_icon.png", "userInterfaceStyle": "automatic", "splash": { "image": "./assets/house_icon.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "assetBundlePatterns": [ "/" ], "ios": { "supportsTablet": true, "bundleIdentifier": "", "googleServicesFile": "./config/firebase/GoogleService-Info.plist", }, "android": { "package": "", "googleServicesFile": "./config/firebase/google-services.json", "config": { "googleMaps": { "apiKey": '' } } }, "web": { "favicon": "./assets/favicon.png" }, "extra": { "eas": { "projectId": "" }, }, "plugins": [ [ "expo-build-properties", { "ios": { "useFrameworks": "static" } } ], "@react-native-firebase/app", "@react-native-firebase/crashlytics", "@react-native-firebase/perf", [ "expo-image-picker", { "cameraPermission": "You may need to take photos of your listing with the device camera.", "photosPermission": "You may need to upload photos of your listing from the photo gallery.", } ], ["expo-tracking-transparency", { "userTrackingPermission": "This identifier will be used to deliver personalized ads to you." }], "./plugins/android_manifest", "./plugins/main_activity" ], "updates": { "url": "***" }, "runtimeVersion": { "policy": "sdkVersion" }, }, ...config })


app.json:

{ "react-native-google-mobile-ads": { "android_app_id": "", "ios_app_id": "", "user_tracking_usage_description": "This identifier will be used to deliver personalized ads to you.", "sk_ad_network_items": [***], } }



HM-23-HM avatar Feb 19 '24 20:02 HM-23-HM

eas update does not have access to SECRETS variables or environment variables that you defined in eas.json. You can use dotenv to export the .env variables locally to eas update. Obviously, you need to maintain the correct SERVER value in your .env.

leons1767 avatar Feb 20 '24 08:02 leons1767

@leons1767 let's say that I am maintaining the correct SERVER value in the .env file, can you explain why eas update changes the value intermittently?

HM-23-HM avatar Feb 20 '24 22:02 HM-23-HM

@leons1767 let's say that I am maintaining the correct SERVER value in the .env file, can you explain why eas update changes the value intermittently?

I don't think it changes the value intermittently, it just picks up whatever the SERVER value is when you run eas update. You can ensure the right environment variables by loading it from .env using dotenv prior to eas update.

leons1767 avatar Feb 21 '24 05:02 leons1767

I deleted a previous comment, because I found the relevant documentation for this issue

mkhoussid avatar Mar 03 '24 08:03 mkhoussid

I deleted a previous comment, because I found the relevant documentation for this issue

Glad that you are able to find the answer from the documentation. Have a nice day!

leons1767 avatar Mar 05 '24 13:03 leons1767

happen to me also, it was intermittenly, because it somehow cached the .env value. so the update needs to be run with --clear-cache flag

MCervenka avatar Apr 17 '24 10:04 MCervenka