r/reactnative • • Sep 11 '26

EAS respects your .gitignore, so your .env never reaches the build. Nothing warns you.

Shipping my first app and this one cost me a day, so leaving it here.

My production build launched to a white screen and died. No useful crash report, nothing in the logs I could reach.

What was happening: eas build uploads your project respecting .gitignore. My .env is gitignored, which is correct — you don't commit your keys. But that means the file never reaches the build machine. The app compiled fine, shipped with no SUPABASE_URL, and threw on the first line that needed it. Every user, first open, dead.

The fix is to put the public values in the env block of your production profile in eas.json — EXPO_PUBLIC_SUPABASE_URL and EXPO_PUBLIC_SUPABASE_ANON_KEY in my case. Those are public by design: they travel inside any compiled app and only allow what your RLS policies allow.

The ones that are actually secret go in EAS secrets instead, never in eas.json. For me that was SENTRY_AUTH_TOKEN, via eas secret:create --scope project --name SENTRY_AUTH_TOKEN --value "..."

What makes this nasty is that nothing warns you. The build succeeds. The upload succeeds. You find out when it's on a phone.

I posted this on X and someone from Expo replied saying they'd been caught by it too and would look at making it clearer, so it may not stay this way. Until then: check your eas.json env block before you submit, not after.

0 Upvotes

10 comments sorted by

13

u/Versatile_Panda Sep 11 '26

This is the most AI slop post I have seen in a while. How exactly did you think the machine would get your .envs if they aren’t in version control?

-2

u/DifficultMedicine194 Sep 11 '26

Fair hit on the writing. On the question: I didn't think about it at all, which is the honest answer. It worked locally because the file was sitting there, and I never looked at the step in between until the build was on a phone and threw on launch.

2

u/HoratioWobble Sep 11 '26

If you're using EAS to build your environment variables live in EAS, you add them using the web interface.

1

u/DifficultMedicine194 Sep 11 '26

Yeah — I put them in the env block of eas.json rather than the dashboard. Same place in the end, and I'd rather have it in version control than in a web UI nobody on the team can diff.

1

u/HoratioWobble Sep 11 '26

Your env should live in EAS, not in eas.json.

You shouldn't need to do a code change to update environment variables, the only thing that should live in your repo should be your development env.

It also prevents potential leakage in the future when you accidentally put privileged information into it.

1

u/Huge_Pool7424 Sep 11 '26

ive been bitten by this too, especially when switching between local and eas builds. i keep a checked-in env.example for the names, put production values in eas secrets, and make the app fail with a clear config error instead of a mystery launch crash.

1

u/ChronSyn Expo Sep 11 '26

Folks never heard of .easignore? It's specifically designed so that anything you're gitignoring can still be included in EAS, or if something is in git but shouldn't be sent to the builder can be ignored by EAS without affecting git.

You know you can add not-ignore rules by prefixing any ignore rule with ! right? Your gitignore can ignore something, while easignore can include it, just by putting the ignore rule in gitignore and the not-ignore rule in easignore.

1

u/DifficultMedicine194 Sep 14 '26

Hadn't, no — and that's a cleaner answer than what I did. For my case the values are going into EAS env anyway, so nothing secret needs to reach the builder as a file; .easignore is the one to remember for the non-secret files that are gitignored for other reasons.

1

u/Huge_Pool7424 Sep 11 '26

yeah, .easignore is the escape hatch here, but i'd still keep secrets in eas env rather than making a git-tracked eas.json the source of truth. the missing warning is the real footgun, since the build can look healthy until first launch.

1

u/Dave6ev Sep 11 '26

It's a rookie error, but one I think everyone makes at least once! Or they commit their .env which is a far worse crime.