Skip to content
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

The .git folder seems to be included in the upload to EAS #2875

Open
davidcarboni opened this issue Feb 4, 2025 · 8 comments
Open

The .git folder seems to be included in the upload to EAS #2875

davidcarboni opened this issue Feb 4, 2025 · 8 comments
Assignees
Labels
bug Something isn't working eas build

Comments

@davidcarboni
Copy link

davidcarboni commented Feb 4, 2025

Build/Submit details page URL

No response

Summary

I got a warning saying "Your project archive is 159 MB. You can reduce its size and the time it takes to upload by excluding files that are unnecessary for the build process in .easignore file."

I used eas build:inspect to check what's being included. The output is as expected, except that it includes the full contents of the .git directory (not something I want shared).

I've tried explicitly adding .git and /.git/** to my .easignore but the directory is still included.

Here's my .easignore contents:

# Only include the app directory when uploading files to EAS

# Ignore everything
*

# Except the app directory and the contents of the directory
!app
!app/**

# Added to see if I can prevent .git from being included
.git
.git/**

Managed or bare?

Managed

Environment

expo-env-info 1.2.2 environment info:
System:
OS: Linux 6.11 Ubuntu 24.10 24.10 (Oracular Oriole)
Shell: 5.2.32 - /bin/bash
Binaries:
Node: 22.13.1 - ~/.nvm/versions/node/v22.13.1/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v22.13.1/bin/yarn
npm: 11.1.0 - ~/.nvm/versions/node/v22.13.1/bin/npm
npmPackages:
expo: ^52.0.30 => 52.0.30
react: 18.3.1 => 18.3.1
react-native: 0.76.6 => 0.76.6
npmGlobalPackages:
eas-cli: 15.0.3
Expo Workflow: managed

Enabled experimental React Native Directory checks. Unset the EXPO_DOCTOR_ENABLE_DIRECTORY_CHECK environment variable to disable this check.
✔ Check package.json for common issues
✔ Check Expo config for common issues
✔ Check native tooling versions
✔ Check if the project meets version requirements for submission to app stores
✔ Check for common project setup issues
✔ Check dependencies for packages that should not be installed directly
✔ Check for app config fields that may not be synced in a non-CNG project
✔ Check for issues with Metro config
✔ Check npm/ yarn versions
✔ Validate packages against React Native Directory package metadata
✔ 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

Error output

No response

Reproducible demo or steps to reproduce from a blank project

  • npx create-expo-app@latest test
  • cd test
  • echo '*' >> .easignore
  • eas build:inspect --platform android --stage archive --output ./target
  • ls target/.git

Output:

branches  description  hooks  info  objects      refs
config    HEAD         index  logs  packed-refs  shallow
@davidcarboni davidcarboni added the needs review Issue is ready to be reviewed by a maintainer label Feb 4, 2025
@sjchmiela
Copy link
Contributor

sjchmiela commented Feb 5, 2025

Hey @davidcarboni!

In v15 we changed how we pack a project into a tarball. Previously, we indeed would be ignoring all .git and only copy files into a tarball. Since v15 we're going to first do a shallow clone of the repository and only then copy all the local files over.

.git directory (not something I want shared)

It's just a shallow clone, so .git directory should only contain the last commit, not the full history. You can confirm that by going into the ./target and running git log.

Hm, rereading your .easignore maybe you have a monorepo and are concerned about sharing anything but the app? In which case you're really don't want to clone the repository? The tarball is removed as soon as we remove the ability to retry a build, so ~2 hours after the build finishes. It is stored encrypted at rest on a private bucket in GCS. On top of that we're SOC2-compliant! All this is to say your monorepo is safe with us.

This being said, I now see how archiving a cloned (even the shallow-cloned) repository is suboptimal — the files are stored both "live" in the working directory and packed in .git/objects/*.pack.

I've got three ideas for you:

  1. discouraged, but possible — turn off using Git when packing your project with EAS_NO_VCS (docs). You'll need to set EAS_NO_VCS=1, EAS_PROJECT_ROOT local environment variable. Then eas-cli really won't use Git.
  2. ignore the warning for now (I'll raise the threshold in the next pull request)
  3. consider using Workflows or GitHub Triggers to start builds from GitHub. This will let you skip uploading tarball from your computer entirely.

EDIT: Actually, let me add support for excluding .git via .easignore. This makes the most sense.

@sjchmiela
Copy link
Contributor

Can you check if [email protected] (latest) fixes the issue for you? It should skip including .git if you have it specified in .easignore.

@weleho
Copy link

weleho commented Feb 5, 2025

I can confirm that [email protected] doesn't include .git

Image

@sjchmiela sjchmiela added bug Something isn't working and removed needs review Issue is ready to be reviewed by a maintainer labels Feb 5, 2025
@sjchmiela sjchmiela self-assigned this Feb 5, 2025
@davidcarboni
Copy link
Author

Thank you very much for this, I really appreciate it!

It sounds helpful that it's a shallow clone (and as far as I could see all the other directories apart from app were empty).

Weirdly it was just .git that was large - the size of that folder seemed large for a shallow clone (although I haven't checked that yet!)

Either way, I'll try the latest, if .git is no longer being included then that seems like a great solution.

@davidcarboni
Copy link
Author

Wonderful, just updated to [email protected] and that's worked.

Thank you so much!

@sjchmiela
Copy link
Contributor

Weirdly it was just .git that was large - the size of that folder seemed large for a shallow clone (although I haven't checked that yet!)

I too did not expect that! I trusted shallow clone to be "small" because it's "just the latest commit" and since I only shallow-cloned small test apps I never had to consider .git size.

However, now, once people started complaining about "big tarball size" warning I started inspecting shallow clones of bigger repositories. Interestingly, a big repository had a big .git in a shallow clone!

I tried some recommendations to make .git directory smaller, like git gc --aggressive --prune=now, git reflog --expire=now --all, but none helped — .git/objects/*.pack remained big.

Then I realized — if I, right now, rm -rf all the files from the repository and left only .git, the files wouldn't be lost… at any point I could git checkout -- . to restore them… so a "backup" of the files must be stored somewhere in .git… and that is what's taking up the other half of tarball size and there's no way to make it smaller per se.


Not to say eas build is discouraged anyhow, but I like to think soon Workflows and Continuous Deployment flow will be so compelling to use that there will be no need to run eas build from your machine. Just commit and see changes live… Ah, back to work! 😃

@voxlz
Copy link

voxlz commented Feb 6, 2025

I've been having a very similar issues with this the last two days. Maybe this is a seperate issue report, but this new shallow copy of the .git folder has broken git submodules. I have a submodule in my project that is not needed in eas build, however if I try to exclude it in .easignore i get:

✔ Incremented versionCode from 168 to 169.
✔ Using remote Android credentials (Expo server)
✔ Using Keystore from configuration: Build Credentials THcPla5Nnh (default)
✖ Compressing project files
Path is a directory: rm returned EISDIR (is a directory) /var/folders/rw/hkq0wjwx2813knvq6fb85ntm0000gn/T/eas-cli-nodejs/fdb64796-a497-4589-afde-39d2a6bc5363-shallow-clone/dictionary

The only reference to this folder is in .git and .easignore. My persumption is that git sees this as a file, while eas seems to consider it a folder. Removing it from easignore seems to bundle fine again. (but bundle is now 100mb larger) Tell me if you want this in a new issue or if this is still .git folder related.

this was not an issue untill 2 days ago.

@sjchmiela
Copy link
Contributor

Hey @voxlz! Your problem is actually #2883. 15.0.5 (latest as of ~2 hours ago) should have fixed it. Let me know if you still have this problem after upgrading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working eas build
Projects
None yet
Development

No branches or pull requests

5 participants