EAS Update: from eas-cli@2.2.0, environment variables are not included in update
See original GitHub issueBuild/Submit details page URL
No response
Summary
When running eas update
, our environment variables are supplied via a .env
file and the dotenv
package.
With the release of eas-cli
2.2.0 this has suddenly stopped working, and the update that is created does not include any environment variables.
Managed or bare?
Managed
Environment
% npx expo-env-info
expo-env-info 1.0.5 environment info: System: OS: macOS 12.6 Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.15.0 - /opt/homebrew/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.5.5 - /opt/homebrew/bin/npm Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8092744 Xcode: 14.1/14B47b - /usr/bin/xcodebuild npmPackages: expo: ~47.0.3 => 47.0.3 react: 18.1.0 => 18.1.0 react-native: 0.70.5 => 0.70.5 npmGlobalPackages: eas-cli: 2.6.0 expo-cli: 6.0.8 Expo Workflow: managed
% expo doctor 🎉 Didn’t find any issues with the project!
Error output
No response
Reproducible demo or steps to reproduce from a blank project
Reproducible demo: https://github.com/GregAtFramework/eas-update-env-issue
npm install -g eas-cli@2.1.0
eas update --branch test --message 2.1.0
npm install -g eas-cli@2.2.0
eas update --branch test --message 2.2.0
npm install -g eas-cli@2.6.0
eas update --branch test --message 2.6.0
Open Expo Go to test the EAS Updates produced.
For version 2.1.0 you get “Foo is: Hello World” (as expected).
However for 2.2.0 and 2.6.0 you get “Foo is:”.
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (2 by maintainers)
Did a bunch of investigation on this.
The reason for this is that
import "dotenv/config"
only runs once since eachimport
only runs once per process.When the CLI gets the config, it:
It does this to prevent corruption/pollution of
process.env
but to still allow developers to customize it for config evaluation.The difference between v2.1.0 and v2.2.0 is:
getExpoConfig
twice and used only the first call as the manifest: https://github.com/expo/eas-cli/compare/v2.1.0...v2.2.0#diff-eabf745ea6a7d52d4573e94ea26a1634f849c8232205268bf97a5801ae32792bL243-L249 The second call though had the same issue as we were seeing in v2.2.0, but it was harder to detect (less prominent).getExpoConfig
numerous times. For example,getDynamicProjectConfigAsync
calls it twice alone and returns the result of the second call.This means that in both versions of the CLI, only the first call to
getExpoConfig
would have the environment if using theimport "dotenv/config"
syntax.The solution is simply to import the module and call config as a method instead:
This matches the behavior I noticed when writing our
app.config.ts
logic, during build only the first time the build step logged the manifest would contain the local envs, and the subsequent logs would be undefined there.Thank you for the investigation and explanation @wschurman