question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EAS Update: from eas-cli@2.2.0, environment variables are not included in update

See original GitHub issue

Build/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:closed
  • Created 10 months ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
wschurmancommented, Nov 17, 2022

Did a bunch of investigation on this.

The reason for this is that import "dotenv/config" only runs once since each import only runs once per process.

When the CLI gets the config, it:

  1. stores current process.env
  2. calls getConfig
  3. restores process.env from prior to the call

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:

This means that in both versions of the CLI, only the first call to getExpoConfig would have the environment if using the import "dotenv/config" syntax.

The solution is simply to import the module and call config as a method instead:

- import "dotenv/config";
+ import dotenv from "dotenv";
+ dotenv.config();
0reactions
MorenoMdzcommented, Nov 18, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using environment variables with EAS Update
Learn how to set up and use environment variables with EAS Update. EAS Build and EAS Update allow setting and getting environment variables...
Read more >
eas cli update is not working for my expo app - Stack Overflow
I'm using eas cli for my app and I tried to update my app with eas cli but It is not totally working...
Read more >
EAS Build seems to ignore environment variables
Hi, We have tried different ways to use environments variables in app.config.js.
Read more >
A comprehensive guide on CI/CD for Expo projects
Learn more: https://docs.expo.dev/eas-update/github-actions" ... we have to add some more environment variables to submit to Testflight and the Appstore.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found