EAS build error: "fatal: not a git repository"

workflow: managed
eas-cli version: eas-cli/0.35.0 darwin-x64 node-v14.17.0

I use a package called git-rev-sync to get the number of commits on the current branch to use as my build number in app.config.js (ios:buildNumber and android:versionCode). This has worked great with the legacy expo build commands. However, when I try to run an EAS build, I get the follow error during the “Read app config” stage:

Error reading Expo config at /Users/expo/workingdir/build/app.config.js:

[git-rev-sync] failed to execute command: fatal: not a git repository (or any of the parent directories): .git

The git-rev-sync package is attempting to run the following command: git rev-list --count HEAD using childProcess.spawnSync if it’s available or falling back to shell.exec. Any ideas on why this wouldn’t work on the eas build servers?

Perhaps there’s a better way to increment my build numbers? I saw that there an autoIncrement option in the eas build config but that requires using app.json which I assume is not a future-proof option.

refer to this doc on how eas build archives your project for more information. tl;dr you can use { "cli": { "requireCommit": true } } to shallow clone your repository

Thanks for the link! However, I’m still getting the same error message (ios & android) after adding "cli": { "requireCommit": true} to my eas.json file. Perhaps the way that git-rev-sync is attempting to execute git commands is not compatible with the eas build environments.

I’ve got it working by using the autoIncrement eas config property and removing the git-rev-sync code. I did have to switch from app.config.js to app.json.

ah sorry i glazed over that specific part of your original post - there will only be a single commit when packaged with git for eas build because it does a shallow clone, so this approach won’t work in that case.