-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running EAS Build with --local
can't access EAS Secrets but also can't access .env.local
#2392
Comments
We are dealing with a similar issue for some reason local builds randomly stopped picking up environment variables. |
The same here, put
But I expected to be .env.local as stated @brentvatne, @dsokal, @szdziedzic can you guys take a look at this?, because it would be great to be able to use .env.local in local eas builds Environmentexpo-env-info 1.2.0 environment info: |
+1 |
Just to confirm, when running eas build with the local flag, it should be able to access EAS project secrets & they should be made available in eas.json & app.config.ts via process.env.[variableName], correct? And this behavior would be the same for remote builds too, correct? I’ve saved my googles-services.json / GoogleService-Info.plist in EAS Secrets for my project & gitingored the files in my repo when I run the build script locally it cannot find the secret files. I just want to make sure I’m understanding this properly. |
I’m encountering a similar issue where updated values in eas.json aren’t being recognized during local builds. |
eas secrets are not supported in local builds |
we load env vars specified in your build profile. if you want to also load |
@brentvatne thanks for that article/reference, I’m thinking specifically about environment variables like a GOOGLE_SERVICES_JSON which it is recommended be stored as a secret on EAS servers & made available to app.config.ts via process.env.GOOGLE_SERVICES_JSON. If we save this file to remote EAS Servers & then want to create a local build, how should we access this file in our app.config.ts properly? I’d love to just write |
@brentvatne Can you reopen this? As stated in the issue, we can't use the ENV variables in EAS config because they're secrets and the config is committed to git. We can't use .env because that's committed too. We can't use .env.locsl because EAS Build --local doesn't recognize .local env files, unlike Expo itself, which does. EAS Build --local should recognize .local env files since it has no access to secrets. Right now, the only way to provide secrets to local builds is to literally prefix the secrets to the command like "VAR=something eas build --local ...", which is crazy |
@kevinhylant The solution that can work here for you is:
{
"name": "my-app",
"scripts": {
"eas-build-pre-install": "echo $GOOGLE_SERVICES_BASE64 | base64 --decode > ./path/to/google-services.json",
// ...
},
"dependencies": {
"expo": "^51.0.0"
// ...
}
} |
@melyux I used your repro steps and I was able to reproduce the issue. However this weird behavior allowing Uploading source maps to Sentry servers (this is where your build fails) is not an action performed through Expo CLI therefore it doesn't have access to It seems like Sentry CLI supports When it comes to making env vars from
|
@szdziedzic I tried the option with the script and once again, if I have the envfile tracked and is not in gitignore then it works perfectly but the second I add my envfile to gitignore the script can't find the file 😬 @melyux have you find any solution? Thanks! |
Yeah, that's true https://github.com/expo/fyi/blob/main/eas-build-archive.md I also think that using direnv to export the env vars form |
@szdziedzic The For |
Even with the direnv solution, unignoring entire files required by the build doesn't work (e.g. @brentvatne Consider re-opening this because of these shortcomings. Life would be much simpler if EAS Build --local behaved the same as EAS Build. |
I exported the path of google-services.json to the environment variable to replace eas secret and it works |
I found a simpler workaround, for both gitignored files that you need in the build process (e.g. 📂 FilesFor files that you need to include in the build process, like Create
You can check which files will be uploaded to EAS Build (and used in EAS Build --local) by running Play with the ☁️ Environment variables from .env filesUnlike the cloud EAS Build, the EAS Build --local command doesn't have access to EAS Secrets. And even if you take the step above to force-include your .gitignored Now, you could just mimic this for your EAS Build --local runs by inlining your environment variables like this: Go to your Expo directory and run
This will read your If you want to include
I added this to my {
...
"scripts": {
"build-prod-android-eas": "npx dotenv -c production -- eas build --platform android --profile production --local",
},
...
} |
@melyux I find this to be an unfair and easily debunked comment. There is so much that you get "for free" (at not cost) from Expo that your comment is insulting. The fact that a company has established a revenue model on their freely available open sourced technology does not make them an evil-only-cares-about-the-money entity. Your writeup shows two things:
|
hey, check it out https://expo.dev/blog/environment-variables I believe that using a new system with sensitive or plain text visibility should be a good fit here 👀 |
@gregfenton My main problem is that it took us many, many hours to find a workaround for this, and then Expo releases the solution (haven't tried it yet) out of nowhere without any sign they were going to do anything about it, on this issue or any of the other similar issues. I'm super happy a possible solution came quickly. At the time I wrote that, I hadn't yet realized that Expo in general was such a stopgap solution, filling the gap between other corporations and projects and subject to their whims, and not a huge team to begin with. We pay for EAS services by the way. |
Build/Submit details page URL
No response
Summary
Cloud EAS Builds have access to EAS Secrets, but local EAS Builds don't. The documentation says the solution is to use environment variables for local EAS Builds instead. However, local EAS Builds only seem to have access to the
.env
file, but not.env.production
nor.env.local
nor any other standard .env file resolution that Expo uses.I tried un-gitignore-ing the
.env.local
files, and it still didn't work. The logs seem to indicate that it's being loaded:But in the end, I still get the Sentry error that the
SENTRY_AUTH_TOKEN
in.env.local
was not loaded:❌ error: Auth token is required for this request.
If I put
SENTRY_AUTH_TOKEN
in the plain old.env.
, the build succeeds.(P.S. Even if .env.local was in .gitignore, this should still be working, since local builds have no access to EAS Secrets and I don't want to commit my .env.local secrets.)
Managed or bare?
Managed
Environment
expo-env-info 1.2.0 environment info:
System:
OS: macOS 14.4.1
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.1.0 - /opt/homebrew/bin/node
npm: 10.7.0 - /opt/homebrew/bin/npm
Watchman: 2024.05.06.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.15.2 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.5, iOS 17.5, macOS 14.5, tvOS 17.5, visionOS 1.2, watchOS 10.5
IDEs:
Xcode: 15.4/15F31d - /usr/bin/xcodebuild
npmPackages:
expo: ^50.0.0 => 50.0.8
react: 18.2.0 => 18.2.0
react-native: 0.73.4 => 0.73.4
npmGlobalPackages:
eas-cli: 9.0.7
Expo Workflow: bare
✔ Check Expo config for common issues
✔ Check package.json for common issues
✔ Check dependencies for packages that should not be installed directly
✔ Check npm/ yarn versions
✔ Check for issues with metro config
✔ Check for common project setup issues
✔ Check for legacy global CLI installed locally
✔ Check that native modules do not use incompatible support packages
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check native tooling versions
✖ Check that packages match versions required by installed Expo SDK
✔ Check that native modules use compatible support package versions for installed Expo SDK
Error output
No response
Reproducible demo or steps to reproduce from a blank project
.env.local
file in the root with an environment variable needed for the build, e.g.SENTRY_AUTH_TOKEN
.env.local
fileeas build --platform ios --local
and see that it claims to load.env.local
variables but they are not made available to parts of the build, e.g. SentryThe text was updated successfully, but these errors were encountered: